After installing MySQL under Linux, it is often necessary to make the following changes to use it more easily
1. Add a remote connection user
Usually we need to remotely connect MySQL database from outside, MySQL database default is not set to allow remote connection of users, we need to add it ourselves.
You can first view the existing users in the current MySQL database:
Use MySQL;
Select Host,user,password from user;
In the results above, host indicates that the user is allowed to connect to the database, the user represents the username, and password represents the password
To add a new user:
GRANT all privileges on * * to ' remotes ' @ '% ' identified by ' PWD ';
Remote is the user name of the new user;% means that the user is allowed to connect from any host, or it can be specified as the IP of a machine; PWD is the password of the new user;
If you are still unable to connect through the remote, you need to comment out the bind-address line in/ETC/MYSQL/MY.CNF
2. Set default encoding is UTF-8
MySQL's default encoding is not utf-8, we need to set the default encoding to Utf-8, so as to avoid the development process encountered a lot of garbled problems
The current encoding can be viewed first
Show variables like '%character% ';
Modify the Encoding
Open/ETC/MYSQL/MY.CNF
Add Default-character-set=utf-8//Set client-side encoding in [client], which is the encoding of statements sent by the client to the server
Add Default-characterr-set=utf-8//Set server-side encoding in [mysqld] to set the encoding for server-saved data
Note: In later versions of version 5.0, the Default-character-set field is not supported in mysqld and will cause MySQL to fail to restart if added. Need to be changed into Character-set-server=utf8
The above modifications are not valid for existing databases and tables, only for future changes.
MySQL-related settings under Linux