How to connect remotely with MySQL in Linux server
This article mainly introduces how MySQL remote connection in Linux server, the article is very detailed, has a certain reference value, interested friends must read it!
msyql database installed on Linux server, can be accessed locally, but I want to access it remotely, after querying the data, I found that MySQL installation under Linux is completed by default, only local access rights, no remote access rights, you need to set access rights for specified users to remotely access the database.
preface
Learn MySQL to reorganize previous non-MK records
described
2003-can't connect to MYSQL
method/step
·First step
Remotely connect to Linux and make sure MySQL is installed on Linux. 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 means username, % means all computers can connect, or you can set an ip address to run the connection,$password means password
·Step 3
Execute flush privileges; command takes effect immediately
FLUSH PRIVILEGES;
·Step 4
Users querying the database
SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;
·Step 5
The requested URL/etc/mysql/my.cnf was not found on this server.
bind-address = 127.0.0.1
Set to bind-address = 0.0.0.0 (device address)
restart
/etc/init.d/mysql restart
·View MYsql global port (default is 3306 )
#View port number
show global variables like 'port';
Configuration is complete.
The above is how MySQL remote connection in Linux server all the content, thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!