CentOS6.9 Installation Mysql5.7First, upload the installation packageIi. Creating a directory for users and MySQL1. Set up a MySQL groupInput command: Groupadd MySQL
2. Build MySQL user and put it into MySQL groupInput command: useradd-r-g MySQL MySQL
3. Set password for MySQL userInput command: passwd MySQL
third, decompression MySQL1. Copy the tar package to the/usr/local/mysql directory2. DecompressionTAR-ZXVF Mysql.tar
3. Change the extracted file name to MySQLIv. Configuring the relevant startup files1. Copy my_default.cnf to/ETC/MY.CNF (automatically read when MySQL starts)Backup my.cnf
Copy my.cnf
2, solve garbled problemInput command: VI/ETC/MY.CNF
Change:
[MySQL]
Default-character-set=utf8
[Mysqld]
Default-storage-engine=innodb
Character_set_server=utf8
3, copy Mysql.server to/etc/init.d/4, modify the/etc/init.d/mysql parameter, give 2 directory locationInput command: Vim/etc/init.d/mysql
Change: Basedir=/usr/local/mysql
Datadir=/usr/local/mysql/data
5, to the directory/usr/local/mysql change ownerInput command: Chown-r mysql:mysql/usr/local/mysql/
v. Initializing the databaseOld command./mysql_install_db--user=mysql--basedir=/usr/local/mysql/--datadir=/usr/local/mysql/data/
New command:./mysqld--initialize--user=mysql--basedir=/usr/local/mysql--datadir=/usr/local/mysql/data
Vi. starting the databaseInput command:./mysqld_safe--user=mysql &;
&; symbols: Throw the current process to the background
Seven, change the passwordView initialization auto-generated password: Cat/root/.mysql_secret
Go to mysql:bin/mysql-uroot-p (paste the password you just copied up)
Reset root Password after login
mysql> SET PASSWORD for ' root ' @localhost = PASSWORD (' 123456 ');
viii. Native connection to the virtual machine database Check to see if only the root localhost permission is granted, if remote Access cannot connect
Mysql> Select Host, User, Password from Mysql.user;
Grant% permissions to root
mysql> Update user Set host = '% ' where host = ' localhost ';
mysql> flush Privileges;
Complete!
ix. Problems1./mysqld_safe:line 586:/var/lib/mysql/mysqld_safe.pid: No file or directoryWorkaround:
(1) Because of the troubleshooting, no error log, so temporarily take the way to supplement the directory
Mkdir-p/var/lib/mysql
Chown Mysql:mysql/var/lib/mysql
(2) After the Supplemental catalogue appears can ' t open and Lock Privilege tables:table ' mysql.user ' doesn ' t exist
DataDir path Error change path in My.ini
2, Mysqld_safe mysqld from PID File/usr/local/mysql/localhost.pid endedQuery log: Discovery: The error means mysqld does not has the access rights to the directory.
Change permissions: Chmod-r 777
A new problem arises: Can ' t open the Mysql.plugin table. Please run Mysql_upgrade to create it.
WORKAROUND: Re-initialize with the old command
3, starting MySQL ..... error! The server quit without updating PID file (/usr/local/mysql/centos6.9.wzy.com.pid).The problem: My.ini Character_set_server=utf8 Write wrong
My.ini was changed to the wrong time before changing the problem datadir=/usr/local/mysql/data