1. Install mysql
thanlon@vivobook:~$ sudo apt-get install mysql-server
2. Review the default user name and password
Mysql After installation is complete, the default user name is not the root, for convenience, usually we need to revise our desired user name and password. Into the configuration file:
root@vivobook:/home/thanlon# vim /etc/mysql/debian.cnf
debian.cnf:
# the Automatically Generated scripts for the Debian the NOT TOUCH the DO.!
[Client]
Host = localhost
User = SYS-MAINT Debian-
password = UwPyJArufIVRvuYC
Socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
Host = localhost
User Debian-SYS-MAINT =
password = UwPyJArufIVRvuYC
socket = /var/run/mysqld/mysqld.sock
can see, there is a default configuration file in the user name and password, where we start with a user name and password to log user profile to the database.
3. Use the default login user mysql
thanlon@vivobook:~$ mysql -udebian-sys-maint -p
4. Modify the user name and password
View the default mysql database:
mysql> show databases;
Use mysql database:
mysql> use mysql
Set the user name and password:
mysql> update user set authentication_string=PASSWORD(“123456”) where user=‘root’;
mysql> update user set plugin=“mysql_native_password”;
mysql> flush privileges;
5. Modify the database encoding
You can use the mysql log in \s
to view the default encoding:
Server characterset: latin1
Db characterset: latin1
Client characterset: utf8
Conn. characterset: utf8
We need to be modified to encode utf8, so:
# 修改配置文件
vim /etc/mysql/conf.d/mysql.cnf
# 加入下面两行
[mysqld]
character-set-server=utf8
View all utf8 encoding will find the:
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
Note also restart mysql.
6. Restart the mysql service
thanlon@vivobook:~$ /etc/init.d/mysql restart;
After the restart mysql service is completed, the next with a user name and password you set up and you're done, time-tested, there is a problem in the comments area.