Centos-6.5 system installs Mysql5.7 through tar.gz package

Note : My.cnf is not required for mysql 5.7, the initialization database is automatically configured to /bin/mysql

1. Before installing mysql, you need to ensure that there is a libaio dependency in the system, use the following command:

yum search libaio
yum install libaio

Or, to see if the system has been installed,
rpm -qa | grep mysql // Check whether the mysql database has been installed on the operating system
rpm -e --nodeps mysql // force delete

2. Download the mysql.5.7 linux compressed package and upload it to centos /usr/local

3. Unzip the mysql installation package to the specified directory, the command is as follows:

tar -zxvf /usr/local/mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz -C /usr/local

Note : You can rename the file The following operations are based on renaming the mysql folder

cd /usr/local
Folder name mysql compressed by mv

4. Add the mysql user group and mysql user for centos (the -s /bin/false parameter specifies that the mysql user only has ownership without login permissions):

groupadd mysql
useradd -r -g mysql -s /bin/false mysql
5. Enter the directory where the mysql software is installed, and the command is as follows:
cd /usr/local/mysql

6. Modify the owner of the current directory to the newly created mysql user, the command is as follows:

chown -R mysql:mysql ./

7. Install mysql, the command is as follows:

./bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize
Be sure to remember the random password: (after the last line localhost:)

8. Start the mysql service with the following command:

./support-files/mysql.server start
9. Restart the mysql service with the following command:
service mysqld restart

10. Use a random password to log in to the mysql database, the command is as follows:

mysql -u root -p

Note: If the command is found, add the mysql command to the system /usr/bin

ln -s /usr/local/mysql/bin/mysql    /usr/bin
11. Enter the mysql operation line and set a new password for the root user (I set it as rootroot):
alter user 'root'@'localhost' identified by 'rootroot';

Note: You cannot enter the database without changing the password

12. Set to allow remote connection to the database, the command is as follows:

Create a user to connect remotely
GRANT ALL PRIVILEGES ON *.* TO 'itoffice'@'%' IDENTIFIED BY 'itoffice' WITH GRANT OPTION;
(The first itoffice means the user name (you can set root according to your needs), % means that all computers can be connected, or you can set an ip address to run the connection, and the second itoffice means the password).

13. Refresh permissions, the command is as follows:

flush privileges

Remotely connect to the database for operation




Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325979133&siteId=291194637