The following mysql tutorial will introduce to you how to create a new user in MySQL and enable remote connection access. I hope it will be helpful to friends in need!
##MySQL creates a new user for the remote database and enables remote connection access
Each project has a database. It is very dangerous if the same MySQL user is used to access each database. Once a project is hacked, its The database account password can also be used to access other databases, which is simply too dangerous! Therefore, for the sake of database security, it is best to create a separate user for each database. Each user can only access the database used for its own project.
1. Create a user
First log in to the remote server and use root to enter MySQL to perform operations.CREATE USER 'username'@'host' IDENTIFIED BY 'password';
2. Authorization:
GRANT privileges ON databasename.tablename TO 'username'@'host'
3. Local login connection test, remote login connection test:
Perform a local login test directly on the remote host:mysql -u username -p
mysql -u username -h host -P port -p
port is the port number, usually 3306Note: The host for this test must have MySQL software locally, otherwise the mysql command cannot be executed.
4. My operation:
CREATE USER 'jal'@'%' IDENTIFIED BY '123456'; GRANT ALL ON jalprodatabase.* TO 'jal'@'%';
This is created. I created a MySQL user. The username is jal and the password is 123456. I can connect to this remote jalprodatabase database on any host.
mysql -u jal -h www.jiailing.com -P 3306 -p
The above is the detailed content of Detailed explanation of MySQL creating new users and enabling remote connection access. For more information, please follow other related articles on the PHP Chinese website!