--CentOS 7.2 二進制安裝MySQL 5.6mysql
1:查看系統版本linux
#cat /etc/redhat-releasesql
CentOS Linux release 7.2.1511 (Core)微信
2:添加用戶和組spa
#groupadd mysql.net
#useradd -g mysql mysqlserver
3:解壓MySQLip
#我是下載好的MySQL,把壓縮包放到了/demo文件夾裏,直接解壓get
#cd /demoit
#tar zxvf mysql-5.6.32-linux-glibc2.5-x86_64.tar.gz
4:修改解壓後文件夾名爲 mysql
#mv mysql-5.6.20-linux-glibc2.5-i686 mysql
5:修改mysql的各級文件夾和文件的建立者、建立組爲mysql(注意語句後面有個.)
#cd mysql
#chown -R mysql .
#chgrp -R mysql .
6:至此mysql已經安裝完了,但還須要初始化,初始化mysql表、test表、infomation表等。
#scripts/mysql_install_db --user=mysql --basedir=/demo/mysql --datadir=/demo/mysql/data
<BUG>若是出現FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db:Data::Dumper,執行:
#yum install -y perl-Module-Install.noarch
<!>從新執行上一步
#scripts/mysql_install_db --user=mysql --basedir=/demo/mysql --datadir=/demo/mysql/data
#cp support-files/mysql.server /etc/init.d/mysqld
7:修改配置文件
# cp my.cnf /etc/my.cnf
# vi /etc/my.cnf
[mysqld]中添加/或修改:
basedir = /demo/mysql
datadir = /demo/mysql/data
port = 3306
server_id = 1
[mysqld_safe]
log-error = /demo/mysql/data/error.log
pid-file = /demo/mysql/data/mysql.pid
user = mysql
tmpdir = /tmp
8:啓動mySQL服務
#ln -s /usr/local/mysql/bin/mysql /usr/bin
#service mysqld start
9:登錄MySQL而且刪除空用戶
#mysql -uroot -p #輸入密碼
mysql>SELECT user,host,password FROM mysql.user; #查詢全部用戶
mysql> UPDATE mysql.user set password = PASSWORD('cyq') WHERE user = 'root';#修改密碼
mysql> update mysql.user set Host='%' where User='root'; #遠程無限制主機IP訪問
mysql> DROP USER ''@localhost; #刪除空用戶
mysql> FLUSH PRIVILEGES; #刷新,搞定!
若有BUG或者須要jar包,加我微信!