Opening method of MySQL remote connection in Linux server
- 2021-08-17 01:15:45
- OfStack
Preface
Learn MySQL and reorganize previous records of non-MK
Describe
Error in connection database if not open: 2003-can 't connect to MYSQL
Methods/Steps
Step 1
Connect to the Linux system remotely and ensure that the MySQL database is installed on the Linux system. Log in to the database.
mysql -u$user -p $pwd
Step 2
Create a user to connect remotely
GRANT ALL PRIVILEGES ON *.* TO '$username'@'%' IDENTIFIED BY '$password' WITH GRANT OPTION;
$username for user name,% for all computers can connect, or you can set an ip address to run the connection, $password for password
• Step 3
Execute flush privileges; The order takes effect immediately
FLUSH PRIVILEGES;
• Step 4
Users who query the database
SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;
• Step 5
Then open it
vim /etc/mysql/my.cnf
bind-address = 127.0. 0.1
Set to
bind-address = 0.0.0.0
(Device address)
Restart
/etc/init.d/mysql restart
· View the MYsql global port (default is 3306)
# View port numbers
show global variables like 'port';
At this point, the configuration has been completed