如何在linux下安装linux导入mysql数据库库并配置

新手园地& & & 硬件问题Linux系统管理Linux网络问题Linux环境编程Linux桌面系统国产LinuxBSD& & & BSD文档中心AIX& & & 新手入门& & & AIX文档中心& & & 资源下载& & & Power高级应用& & & IBM存储AS400Solaris& & & Solaris文档中心HP-UX& & & HP文档中心SCO UNIX& & & SCO文档中心互操作专区IRIXTru64 UNIXMac OS X门户网站运维集群和高可用服务器应用监控和防护虚拟化技术架构设计行业应用和管理服务器及硬件技术& & & 服务器资源下载云计算& & & 云计算文档中心& & & 云计算业界& & & 云计算资源下载存储备份& & & 存储文档中心& & & 存储业界& & & 存储资源下载& & & Symantec技术交流区安全技术网络技术& & & 网络技术文档中心C/C++& & & GUI编程& & & Functional编程内核源码& & & 内核问题移动开发& & & 移动开发技术资料ShellPerlJava& & & Java文档中心PHP& & & php文档中心Python& & & Python文档中心RubyCPU与编译器嵌入式开发驱动开发Web开发VoIP开发技术MySQL& & & MySQL文档中心SybaseOraclePostgreSQLDB2Informix数据仓库与数据挖掘NoSQL技术IT业界新闻与评论IT职业生涯& & & 猎头招聘IT图书与评论& & & CU技术图书大系& & & Linux书友会二手交易下载共享Linux文档专区IT培训与认证& & & 培训交流& & & 认证培训清茶斋投资理财运动地带快乐数码摄影& & & 摄影器材& & & 摄影比赛专区IT爱车族旅游天下站务交流版主会议室博客SNS站务交流区CU活动专区& & & Power活动专区& & & 拍卖交流区频道交流区
白手起家, 积分 16, 距离下一级还需 184 积分
论坛徽章:0
mysql官网开始发布相关的5.6系列的各个版本,对于mysql5.6系列的版本对一起的版本进行了全局性的细节性加强
从今年3月份开始mysql官网开始发布相关的5.6系列的各个版本,对于mysql5.6系列的版本对一起的版本进行了全局性的细节性加强;
以下是在虚拟机中配置的mysql5.6.10源码安装的过程分享记录下:
[root@mysql5 ~]# groupadd mysql
[root@mysql5 ~]# useradd -r -g mysql mysql
[root@mysql5 ~]# ls
anaconda-ks.cfg install.log install.log.syslog mysql-5.6.10.tar.gz
[root@mysql5 ~]# cd /usr/local/
[root@mysql5 local]# ls
bin etc games include lib libexec sbin share src
[root@mysql5 local]# cp /root/mysql-5.6.10.tar.gz /usr/local/
[root@mysql5 local]# ll
total 34468
drwxr-xr-x 2 root root 4096 Jan 27 2010 bin
drwxr-xr-x 2 root root 4096 Jan 27 2010 etc
drwxr-xr-x 2 root root 4096 Jan 27 2010 games
drwxr-xr-x 2 root root 4096 Jan 27 2010 include
drwxr-xr-x 2 root root 4096 Jan 27 2010 lib
drwxr-xr-x 2 root root 4096 Jan 27 2010 libexec
-rw-r--r-- 1 root root
Apr 17 00:55 mysql-5.6.10.tar.gz
drwxr-xr-x 2 root root 4096 Jan 27 2010 sbin
drwxr-xr-x 4 root root 4096 Apr 17 00:32 share
drwxr-xr-x 2 root root 4096 Jan 27 2010 src
[root@mysql5 local]# tar -zxvf mysql-5.6.10.tar.gz
[root@mysql5 local]# cd mysql-5.6.10
make && make install
[root@mysql5 mysql-5.6.10]# chown -R mysql.mysql /usr/local/mysql
[root@mysql5 mysql-5.6.10]#
[root@mysql5 mysql-5.6.10]# cd /usr/local/mysql/scripts/
[root@mysql5 scripts]# ./mysql_install_db --user=mysql --basedir=/usr/local/mys
ql --datadir=/usr/local/mysql/data
Installing MySQL system tables... 01:26:58 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
01:26:58 18715 [Note] InnoDB: The InnoDB memory heap is disabled
01:26:58 18715 [Note] InnoDB: Mutexes and rw_locks use InnoDB's own implementation
01:26:58 18715 [Note] InnoDB: Compressed tables use zlib 1.2.3
01:26:58 18715 [Note] InnoDB: CPU does not support crc32 instructions
01:26:58 18715 [Note] InnoDB: Initializing buffer pool, size = 128.0M
01:26:58 18715 [Note] InnoDB: Completed initialization of buffer pool
01:26:58 18715 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
01:26:59 18715 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
01:26:59 18715 [Note] InnoDB: Database physically writes the file full: wait...
01:26:59 18715 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
01:26:59 18715 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
01:26:59 18715 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
01:26:59 18715 [Warning] InnoDB: New log files created, LSN=45781
01:26:59 18715 [Note] InnoDB: Doublewrite buffer not found: creating new
01:26:59 18715 [Note] InnoDB: Doublewrite buffer created
01:26:59 18715 [Note] InnoDB: 128 rollback segment(s) are active.
01:26:59 18715 [Warning] InnoDB: Creating foreign key constraint system tables.
01:26:59 18715 [Note] InnoDB: Foreign key constraint system tables created
01:26:59 18715 [Note] InnoDB: Creating tablespace and datafile system tables.
01:26:59 18715 [Note] InnoDB: Tablespace and datafile system tables created.
01:26:59 18715 [Note] InnoDB: Waiting for purge to start
01:26:59 18715 [Note] InnoDB: 1.2.10 log sequence number 0
01:26:59 18715 [Note] Binlog end
01:26:59 18715 [Note] InnoDB: FTS optimize thread exiting.
01:26:59 18715 [Note] InnoDB: Starting shutdown...
01:27:00 18715 [Note] InnoDB: S log sequence number 1625977
Filling help tables... 01:27:00 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
01:27:00 18738 [Note] InnoDB: The InnoDB memory heap is disabled
01:27:00 18738 [Note] InnoDB: Mutexes and rw_locks use InnoDB's own implementation
01:27:00 18738 [Note] InnoDB: Compressed tables use zlib 1.2.3
01:27:00 18738 [Note] InnoDB: CPU does not support crc32 instructions
01:27:00 18738 [Note] InnoDB: Initializing buffer pool, size = 128.0M
01:27:00 18738 [Note] InnoDB: Completed initialization of buffer pool
01:27:00 18738 [Note] InnoDB: Highest supported file format is Barracuda.
01:27:00 18738 [Note] InnoDB: 128 rollback segment(s) are active.
01:27:00 18738 [Note] InnoDB: Waiting for purge to start
01:27:01 18738 [Note] InnoDB: 1.2.10 log sequence number 1625977
01:27:01 18738 [Note] Binlog end
01:27:01 18738 [Note] InnoDB: FTS optimize thread exiting.
01:27:01 18738 [Note] InnoDB: Starting shutdown...
01:27:02 18738 [Note] InnoDB: S log sequence number 1625987
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h mysql5.6 password 'new-password'
Alternatively you can run:
/usr/local/mysql/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd . ; /usr/local/mysql/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd mysql- perl mysql-test-run.pl
Please report any problems with the ./bin/mysqlbug script!
The latest information about MySQL is available on the web at
Support MySQL by buying support/licenses at
New default config file was created as /usr/local/f and
will be used by default by the server when you start it.
You may edit this file to change server settings
WARNING: Default config file /f exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server
[root@mysql5 scripts]#
[root@mysql5 scripts]# cd /usr/local/mysql/support-files/
[root@mysql5 support-files]# cp mysql.server /etc/rc.d/init.d/mysql
[root@mysql5 support-files]# cp f /f
cp: overwrite `/f'? y
[root@mysql5 support-files]#
[root@mysql5 support-files]# chkconfig -add mysql
-add: unknown option
[root@mysql5 support-files]# chkconfig --add mysql
[root@mysql5 support-files]# chkconfig mysql on
[root@mysql5 support-files]# service mysql start
Starting MySQL. [ OK ]
[root@mysql5 support-files]#
[root@mysql5 data]# mysql -u mysql -p -S /tmp/mysql.sock
Enter password:
Welcome to the MySQL monitor. C or \g.
Your MySQL connection id is 1
Server version: 5.6.10 Source distribution
Type '' or '\h' for help. Type '\c' to clear the buffer.
--------------
mysql Ver 14.12 Distrib 5.0.77, for redhat-linux-gnu (i686) using readline 5.1
Connection id: 1
Current database:
Current user: mysql@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.6.10 Source distribution
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: latin1
Db characterset: latin1
Client characterset: latin1
Conn. characterset: latin1
UNIX socket: /tmp/mysql.sock
Uptime: 3 min 38 sec
Threads: 1 Questions: 5 Slow queries: 0 Opens: 67 Flush tables: 1 Open tables: 60 Queries per second avg: 0.022
--------------
&&nbsp|&&nbsp&&nbsp|&&nbsp&&nbsp|&&nbsp&&nbsp|&&nbsp
大富大贵, 积分 12329, 距离下一级还需 7671 积分
论坛徽章:16
白手起家, 积分 92, 距离下一级还需 108 积分
论坛徽章:0
不错,但是不用那么复杂吧, 这个看起来比较简单的
白手起家, 积分 16, 距离下一级还需 184 积分
论坛徽章:0
这个你也可以参考下。
白手起家, 积分 16, 距离下一级还需 184 积分
论坛徽章:0
Linux安装mysql——源码安装
1.假设已经有mysql-5.5.10.tar.gz以及cmake-2.8.4.tar.gz两个源文件
(1)先安装cmake(mysql5.5以后是通过cmake来编译的)
[root@ rhel5 local]#tar -zxv -f cmake-2.8.4.tar.gz
[root@ rhel5 local]#cd cmake-2.8.4
[root@ rhel5 cmake-2.8.4]#./configure
[root@ rhel5 cmake-2.8.4]#make
[root@ rhel5 cmake-2.8.4]#make install
(2)创建mysql的安装目录及数据库存放目录
[root@ rhel5~]#mkdir -p /usr/local/mysql& && && && && &&&//安装mysql
[root@ rhel5~]#mkdir -p /usr/local/mysql/data& && && && &//存放数据库
(3)创建mysql用户及用户组
[root@ rhel5~]groupadd mysql
[root@ rhel5~]useradd -r -g mysql mysql
(4)安装mysql
[root@ rhel5 local]#tar -zxv -f mysql-5.5.10.tar.gz
[root@ rhel5 local]#cd mysql-5.5.10
[root@ rhel5 mysql-5.5.10]#cmake .
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-DMYSQL_DATADIR=/usr/local/mysql/data
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DEXTRA_CHARSETS=all
-DENABLED_LOCAL_INFILE=1
[root@ rhel5 mysql-5.5.10]#make
[root@ rhel5 mysql-5.5.10]#make install
参数说明:
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql& && &&&//安装目录
-DINSTALL_DATADIR=/usr/local/mysql/data& && && &//数据库存放目录
-DDEFAULT_CHARSET=utf8& && && && && && &&&    //使用utf8字符
-DDEFAULT_COLLATION=utf8_general_ci& && && && &//校验字符
-DEXTRA_CHARSETS=all& && && && && && && && &    //安装所有扩展字符集
-DENABLED_LOCAL_INFILE=1& && && && && && &&&  &&//允许从本地导入数据
注意事项:
重新编译时,需要清除旧的对象文件和缓存信息。
# make clean
# rm -f CMakeCache.txt
# rm -rf /f
(1)设置目录权限
[root@ rhel5~]# cd /usr/local/mysql
[root@ rhel5 mysql]# chown -R root:mysql . //把当前目录中所有文件的所有者所有者设为root,所属组为mysql
[root@ rhel5 mysql]# chown -R mysql:mysql data
[root@ rhel5 mysql]# cp support-files/f /f //将mysql的启动服务添加到系统服务中
(3)创建系统数据库的表
[root@ rhel5 mysql]# cd /usr/local/mysql
[root@ rhel5 mysql]# scripts/mysql_install_db --user=mysql
(4)设置环境变量
[root@ rhel5~]# vi /root/.bash_profile
在PATH=$PATHHOME/bin添加参数为:
PATH=$PATHHOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib
[root@ rhel5~]#source /root/.bash_profile
(5)手动启动mysql
[root@ rhel5~]# cd /usr/local/mysql
[root@ rhel5 mysql]# ./bin/mysqld_safe --user=mysql &   //启动MySQL,但不能停止
启动日志写在此文件下:/usr/local/mysql/data/localhost.err
关闭MySQL服务
[root@ rhel5 mysql]# mysqladmin -u root -p shutdown  //这里MySQL的root用户还没有配置密码,所以为空值。需要输入密码时,直接点回车键即可。
(6)另一种简单的启动mysql的方法(mysql已经被添加到系统服务中)
[root@ rhel5~]# service mysql.server start&&
[root@ rhel5~]# service mysql.server stop
[root@ rhel5~]# service mysql.server restart
如果上述命令出现:mysql.server 未识别的服务
则可能mysql还没添加到系统服务中,下面用另一种方法添加:
[root@ rhel5 mysql]# cp support-files/mysql.server&&/etc/init.d/mysql //将mysql的启动服务添加到系统服务中
注意:主要是将mysql.server拷贝到/etc/init.d中,命名为mysql。在有的系统中,mysql.server在/usr/local/mysql/share/mysql/mysql.server中,而本系统中,mysql.server在/usr/local/mysql/support-files/mysql.server中。
然后再用#service mysql start 来启动mysql即可。
(7)修改MySQL的root用户的密码以及打开远程连接
[root@ rhel5~]# mysql -u root mysql
mysql& GRANT ALL PRIVILEGES ON *.* TO root@&%& IDENTIFIED BY &root&;  //为root添加远程连接的能力。
mysql&update user set Password = password('xxxxxx') where User='root';
mysql&select Host,User,Password&&from user where User='root';
mysql&exit
重新登录:mysql -u root -p
若还不能进行远程连接,则关闭防火墙
[root@ rhel5~]# /etc/rc.d/init.d/iptables stop
注:如果不能远程连接,出现错误mysql error number 1130,则加入下面语句试试:
mysql&GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '******' WITH GRANT OPTION;编程开发子分类ubuntu15.10安装mysql数据库
(1)在终端下执行sudo apt-get install mysql-server-5.6 命令
(2)一路按回车键,等安装好之后,再设置密码。
(3)安装成功之后,执行mysql -u root命令,进入数据库,如下:
Welcome to the MySQL monitor.& C or \g.&
Your MySQL connection id is 12&
Server version: 5.6.27-0ubuntu1 (Ubuntu)
Copyright (c) , Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its&
affiliates. Other names may be trademarks of their respective&
Type '' or '\h' for help. Type '\c' to clear the current input statement.
现在就可以设置root密码了,执行grant all privileges on *.* to root@&%& identified by &passwd& ;把密码设置为passwd。
腾讯云CentOS7.0使用yum安装mysql:
CentOS 7.1上编译安装MySQL 5.7.10:
Ubuntu14.04编译安装mysql5.6.26:
Ubuntu安装mysql和简单操作:
Ununtu 15.04安装MySql(Django连接Mysql):
------分隔线----------------------------最近在学习R语言,看到R与数据库交互这一部分,就自己动手实践了一下,数据库选择的是mysql,主要记录下linux下怎么安装mysql。
网上的很多资料都有相关的文章,这里只是记录下自己安装过程中遇到的问题和解决方法:
linux内核版本:
~$ uname -a
Linux naci 3.19.0-16-generic #16-Ubuntu SMP Thu Apr 30 16:09:58 UTC
x86_64 x86_64 GNU/Linux
1.首先在liunx下安装Mysql数据库
~$ sudo apt-get install mysql-server
#安装Mysql服务器端
~$ ps -aux|grep mysql
#检查Mysql服务器进程
0:00 mysql -u root -p
0:00 /bin/sh /usr/bin/mysqld_safe
0:01 /usr/sbin/mysqd --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --log-error=/var/log/mysql/error.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock --port=3306
0:00 grep --color=auto mysql
~$ netstat -nlt|grep 3306
#检查Mysql服务器占用端口
0 127.0.0.1:3306
~$ /etc/init.d/mysql status
# 通过启动命令检查Mysql服务器状态
Loaded: loaded (/lib/systemd/system/mysql. vendor preset: enabled)
Active: active (running) since 四
09:51:13 CST; 43min ago
Process: 25126 ExecStartPost=/usr/share/mysql/mysql-systemd-start post (code=exited, status=0/SUCCESS)
Process: 25122 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
~$ service mysql status
# 通过系统服务检查Mysql服务器状态
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql. vendor preset: enabled)
Active: active (running) since 四
09:51:13 CST; 44min ago
Process: 25126 ExecStartPost=/usr/share/mysql/mysql-systemd-start post (code=exited, status=0/SUCCESS)
Process: 25122 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)~$ whereis mysql
# 查看mysql各个文件安装的目录mysql: /usr/bin/mysql /usr/lib/mysql /etc/mysql /usr/include/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz
2.访问和配置Mysql
$ mysql -u root -p
Enter password:
mysql默认的字符集为latin1的,所以要改为utf8的。很多网上的文章执行&sudo vi /etc/f&,可是打开一看,里面就两行话:
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
想来mysql的配置文件应该是在那两个文件夹下面,于是尝试之下打开了/etc/mysql/mysql.conf.d/ 下的f文件,执行下面的命令:
~$ sudo vi /etc/mysql/mysql.conf.f
default-character-set=utf8
[mysqld_safe]
= /var/run/mysqld/mysqld.sock
character-set-server=utf8
collation-server=utf8_general_ci...
注:棕色部分是添加的内容
重启mysql服务,并查看字符集的设置情况:
~$ sudo /etc/init.d/mysql restart
~$ mysql -u root -p
mysql& show variables like "%char%"
+--------------------------+----------------------------+
| Variable_name
+--------------------------+----------------------------+
| character_set_client
| character_set_connection | utf8
| character_set_database
| character_set_filesystem | binary
| character_set_results
| character_set_server
| character_set_system
| character_sets_dir
| /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
阅读(...) 评论()linux下yum安装 mysql 及详细配置及默认目录修改 - What is java - ITeye技术网站
博客分类:
一、[root@sample ~]# yum -y install mysql-server  ← 安装MySQL
Installed: mysql-server.i386 0:4.1.20-1.RHEL4.1
Dependency Installed: mysql.i386 0:4.1.20-1.RHEL4.1 perl-DBD-MySQL.i386 0:2. perl-DBI.i386 0:1.40-8
[root@sample ~]# vi /f  ← 编辑MySQL的配置文件
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1  ← 找到这一行,在这一行的下面添加新的规则,让MySQL的默认编码为UTF-8
default-character-set = gbk  ← 添加这一行
然后在配置文件的文尾填加如下语句:
default-character-set = gbk
三、启动MySQL服务
[root@sample ~]# chkconfig mysqld on  ← 设置MySQL服务随系统启动自启动
如果上述命令失败,显示
bash: chkconfig: command not found,见本文最下面解决方法
[root@sample ~]# chkconfig --list mysqld  ← 确认MySQL自启动
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off  ← 如果2--5为on的状态就OK
[root@sample ~]# /etc/rc.d/init.d/mysqld start  ← 启动MySQL服务
注:如果这一部执行失败有可能是/var/lib/mysql 没有数据库文件,会报【 Fatal error: Can't open and
lock privilege tables: Table 'mysql.host' doesn't
exist】,这是需要执行mysql_install_db命令就OK了。
四、MySQL的root用户设置密码
MySQL在刚刚被安装的时候,它的root用户是没有被设置密码的。首先来设置MySQL的root密码。
[root@sample ~]# mysql -u root  ← 用root用户登录MySQL服务器
:如果出现错误Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2),
:则查看mysql是否启动 /etc/rc.d/init.d/mysqld status, 没有启动则/etc/rc.d/init.d/mysqld start
mysql& select user,host,password from mysql.  ← 查看用户信息
mysql&set password for root@localhost=password('在这里填入root密码');  ← 设置root密码
mysql&set password for root@域名=password('在这里填入root密码');
mysql& delete from mysql.user where user='';  ← 删除匿名用户
mysql& exit  ← 退出MySQL服务器【测试设置的密码是否正确】
五、删除测试用数据库
mysql&  ← 查看系统已存在的数据库
mysql&  ← 删除名为test的空数据库
六、对MySQL进行测试。包括建立新用户,以及用对关系性数据库进行数据库操作的指令来试着建立数据库及数据表。这里,新建用户以 sleinetpub为例。
[root@sample ~]# mysql -u root -p  ← 通过密码用root登录
Enter password:  ← 在这里输入密码
mysql& grant all privileges on test.* to sleinetpub@localhost identified by '在这里定义密码';  ← 建立对test数据库有完全操作权限的名为sleinetpub的用户
mysql& select user from mysql.user where user='sleinetpub';  ← 确认sleinetpub用户的存在与否
mysql& exit  ← 退出MySQL服务器
[root@sample ~]# mysql -u sleinetpub -p  ← 用新建立的sleinetpub用户登录MySQL服务器
Enter password:  ← 在这里输入密码
mysql&   ← 建立名为test的数据库
mysql&  ← 查看系统已存在的数据库
mysql& use test  ← 连接到数据库
mysql& create table test(num int, name varchar(50));  ← 在数据库中建立表
mysql&  ← 查看数据库中已存在的表
mysql&  ← 删除表
mysql&  ← 查看已存在的数据库
Empty set (0.01 sec)  ← 确认test数据库已被删除(这里非root用户的关系,看不到名为mysql的数据库)
mysql& exit  ← 退出MySQL服务器
七、删除测试用过的遗留用户
[root@sample ~]# mysql -u root -p  ← 通过密码用root登录
Enter password:  ← 在这里输入密码
mysql& revoke all privileges on *.* from sleinetpub@  ← 取消sleinetpub用户对数据库的操作权限
mysql& delete from mysql.user where user='sleinetpub' and host='localhost';  ← 删除sleinetpub用户
mysql& select user from mysql.user where user='sleinetpub';  ← 查找用户sleinetpub,确认已删除与否
Empty set (0.01 sec)  ← 确认sleinetpub用户已不存在
mysql&  ← 刷新,使以上操作生效
mysql& exit
八、最后,重新启动一次HTTP服务。
[root@undefined /]# /etc/rc.d/init.d/mysqld stop  ← 停止HTTP服务
[root@undefined /]# /etc/rc.d/init.d/mysqld start ← 启动HTTP服务
配置文件: /f中 datadir=/var/lib/mysql 定义的为数据库存放地址,修改数据库存放地址见本文最下面
bash: chkconfig: command not found错误:
[root@xuniji ~]# chkconfig
bash: chkconfig: command not found -------->环境变量里没有chkconfig的目录
[root@xuniji ~]# rpm -aq |grep chkconfig ------看是否安装了chkconfig
chkconfig-1.3.30.1-2
[root@xuniji ~]# export PATH=/sbin:$PATH
[root@xuniji ~]# chkconfig
chkconfig version 1.3.30.1 - Copyright (C)
Red Hat, Inc.
This may be freely redistributed under the terms of the GNU Public License.
chkconfig --list [name]
chkconfig --add
chkconfig --del
chkconfig [--level ]
[root@xuniji ~]# echo $PATH ------------打印环境变量
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/gtl/bin
[root@xuniji ~]# PATH="$PATH":/sbin ------环境变量里加进去:/sbin
[root@xuniji ~]# echo $PATH
------------再次打印看是否成功加进去
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/gtl/bin:/sbin
到这里就解决了!
修改数据库存放目录
默认在:/var/lib/mysql/ 按目录存放
0.关闭mysql
1.移动/var/lib/mysql/目录下的数据库目录到自定义目录,如:/home/mysql_datas
原数据库目录结构
比如/var/lib/mysql/mysql
/var/lib/mysql/business
/var/lib/mysql/upper等
移动后结构
比如/home/mysql_datas/mysql
/home/mysql_datas/business
/home/mysql_datas/upper等
2.修改/f中的如下两项到新目录的位置
datadir=/home/mysql_datas
3.修改mysql启动脚本中上面两项的位置
#vi /etc/rc.d/init.d/mysqld
get_mysql_option mysqld datadir "/var/lib/mysql"改为
get_mysql_option mysqld datadir "/home/mysql_datas/mysql"
4.启动mysql
浏览 16594
浏览: 115455 次
来自: 北京
谢啦,楼主,顶
方法4: 缓冲整个文件 ?
为什么要缓存整个文件?
Buffe ...

我要回帖

更多关于 linux导入mysql数据库 的文章

 

随机推荐