1, the MySQL service process to stop: (the whole process please pay attention to the backup.) Turn the SELinux off! )
2. move/var/lib/mysql Entire directory to/data/mysql
3. Locate the MY.CNF configuration file
To ensure that MySQL works correctly, you need to indicate where the Mysql.sock file is generated. Modify the value in the Socket=/var/lib/mysql/mysql.sock line to the right of the equals sign:/data/mysql/mysql.sock. The operation is as follows:
VI my.cnf (edit my.cnf file with VI tool, find the following data modified) # The MySQL server[mysqld] Port = 3306#socket =/var/lib/mysql/mysql.sock (original content, in order to more Secure with "#" comment this line) socket =/data/mysql/mysql.sock (plus this line)
4. Modify MySQL startup script/etc/init.d/mysql
Vi/etc/init.d/mysql#datadir=/var/lib/mysql (Note this line) Datadir=/home/data/mysql (plus this line)
If it is CentOS also need to change/usr/bin/mysqld_safe relevant file location;
Finally make a mysql.sock link:
In-s/home/data/mysql/mysql.sock/var/lib/mysql/mysql.sock
5, 7, restart the MySQL service
/etc/init.d/mysqld start
or restart Linux with the reboot command
If the work is moving properly, otherwise check the previous 7 steps. Also pay attention to the owner and permission of the directory.
Copy Content to Clipboard
SELinux try to shut down
/etc/selinux/config
Allow Ubuntu to connect remotely under MySQL
The first step:
Vim/etc/mysql/my.cnf Found bind-address = 127.0.0.1
Comment out this line, such as: #bind-address = 127.0.0.1
or instead: Bind-address = 0.0.0.0
Allow any IP access;
Or specify an IP address yourself.
Restart Mysql:sudo/etc/init.d/mysql restart
Step Two:
Authorized users can connect remotely
Grant all privileges on * * to [email protected] '% ' identified by ' password ' with GRANT option;
Flush privileges;
The first line of the command is interpreted as follows, * *: The first * represents the database name, and the second * represents the table name. This means that all tables in the database are licensed to the user. Root: Grant root account. "%": indicates that the authorized user IP can be specified, which means that any IP address can access the MySQL database. "Password": Assign the password of the account, here the password itself is replaced with your MySQL root account password.
The second line of command is to refresh the permission information, that is, let our settings take effect immediately.
Note
MySql5.6 Operation times Error: must SET PASSWORD before executing this statement resolution
mysql> SET PASSWORD = PASSWORD (' 123456 ');
Query OK, 0 rows affected (0.03 sec)
mysql> CREATE DATABASE Roger;
Query OK, 1 row Affected (0.00 sec)
That is, with mysql> set PASSWORD = PASSWORD (' 123456 '), this sentence reset the password again!
This article is from the "Network Engineering topic" Blog, please be sure to keep this source http://houzhibo.blog.51cto.com/3103241/1597821
MySQL modifies the storage location and opens the remote