Generally, you will be asked to enter the root password in the previous step. if you do not have the root password, you must change it for security reasons! First, let's see if your mysql has no password: If you can see the mysql version information, it proves that there is no password for MySQL at present. Run mysqladminpasswordxxxxxx to change the password: # mysqladminpasswordxxxxx you will be asked to enter the root password in the previous step. if not, you must change your password to ensure security!
Let's take a look at your
MysqlIs there really no password:
If you can see the mysql version information, it proves that MySQL currently has no password.
Run mysqladmin password xxxxxx to change the password:
| # Mysqladmin password xxxxxx |
Here, xxxxxx is your new password.
Now you need to run mysqladmin version -- user = root -- pass, and then enter the password to view the version number and other information.
Note: The -- user = root -- pass part in the preceding command can be abbreviated as-u root-p. Let's test whether the password has taken effect:
# Mysqladmin version-u root-p Enter password: |
3. enable Port 3306 listening
This work should be careful. In security considerations, by default, Debian closes port 3306. Because many hackers use it to attack your system. If you do not use other machines to access the database, do not open this port.
Modify/etc/mysql/my. cnf and find:
Comment it out:
You can also modify some attributes in/etc/mysql/my. conf.
This line originally exists: bind-address = 127.0.0.1, which means only the local machine can access the service and is willing to ensure data security. To allow remote machines to access the MySQL database service, you can change bind-address:
1. bind-address = 0.0.0.0
2. comment out the bind-address line directly.
4. modify the default character set
Let MySQL use simplified Chinese as the default character set. Edit/etc/init. d/mysql and find this line:
| /Usr/bin/safe_mysqld>/dev/null 2> & 1 & |
Changed:
| /Usr/bin/safe_mysqld> -- default-character-set = gb2312>/dev/null 2> & 1 & |
OK. restart MySQL:
| #/Etc/init. d/mysql restart |