CentOS 6.5 二進制安裝MySQL 5.6mysql
1:查看系統版本linux
[root@10-4-5-9 mysql]# cat /etc/redhat-release CentOS release 6.5 (Final)
2:下載MySQL5.6二進制包c++
#wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.20-linux-glibc2.5-i686.tar.gz
3:添加用戶和組sql
#groupadd mysql #useradd -g mysql mysql
4:安裝mysql到/usr/local/mysql下cdn
#cd /usr/local #tar zxvf /{MySQL5.6_path}/mysql-{version}.tar.gz 例如個人配置路徑爲: #cd /usr/local #tar zxvf /root/mysql-5.6.20-linux-glibc2.5-i686.tar.gz
5:修改解壓後文件夾名爲 mysqlserver
#mv mysql-5.6.20-linux-glibc2.5-i686 mysql
6:修改mysql的各級文件夾和文件的建立者、建立組爲mysql(注意語句後面有個.)blog
cd mysql chown -R mysql . chgrp -R mysql .
7:至此mysql已經安裝完了,但還須要初始化,初始化mysql表、test表、infomation表等。ip
#scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
#cp support-files/mysql.server /etc/init.d/mysqld
--user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
PS:該步驟有可能會報錯誤 安裝須要的包便可:libstdc++.so.6和libaio.so.1和libncurses.so.5
8:修改配置文件get
[root@10-4-5-9 mysql]# cp my.cnf /etc/my.cnf /usr/local/mysql [root@10-4-5-9 mysql]# vi /etc/my.cnf
[mysqld]中添加: basedir = /usr/local/mysql datadir = /usr/local/mysql/data port = 3306 server_id = 1
9:啓動mySQL服務it
#ln -s /usr/local/mysql/bin/mysql /usr/bin
#service mysqld start
10:登錄MySQL而且刪除空用戶
mysql> SELECT user,host,password FROM mysql.user; +------+-----------+----------+ | user | host | password | +------+-----------+----------+ | root | localhost | | | root | 10-4-5-9 | | | root | 127.0.0.1 | | | root | ::1 | | | | localhost | | | | 10-4-5-9 | | +------+-----------+----------+ 6 rows in set (0.00 sec) mysql> UPDATE mysql.user set password = PASSWORD('gechong') WHERE user = 'root'; mysql> DROP USER ''@localhost; mysql> FLUSH PRIVILEGES;