table of Contents
1 mysql service related commands under ubuntu
1.1 Installation
sudo apt-get install mysql-server
1.2 Start
service mysql start
1.3 Restart
service mysql restart
1.4 Close
service mysql stop
1.5 Check whether the installation is successful
sudo netstat -tap | grep mysql
1.6 Enter the shell interface
mysql -u root -p
2 Set mysql to support Chinese
2.1 View character variable encoding
show variables like “char%”;
2.2 Edit the configuration file
sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
2.3 Add
Add a line character_set_server=utf8 under [mysqld]
2.4 Restart mysql service
service mysql restart
2.5 Login to re-check
show variables like “char%”;
3 Create mysql for remote access
3.1 Need to modify the /etc/mysql/mysql.conf.d/mysqld.cnf file.
Find the line bind-address = 127.0.0.1 and
change it to bind-address = 0.0.0.0
3.2 After connecting to the server, the operating mysql system database
command is:
mysql -u root -p
use mysql;
3.3 Query the user table command:
select User,authentication_string,Host from user;
(It can also be seen here that the host defaults to localhost access authority)
3.4 Create an accessible user name or password
GRANT ALL PRIVILEGES ON *.* TO'account'@'%' IDENTIFIED BY'password';
3.5 Flush privileges: flush privileges;
3.6 Restart the mysql service: service mysql restart
4 Install Mycli autocompletion
sudo apt-get install mycli
4.1 Link local Mysql
mycli -uroot -hlocalhost
4.2 Link to remote mysql
mycli -uroot -h192.168.1.105 -p3306
5 Database related operation commands
show databases; view which databases
use dbname; select the database
show tables; view which tables are in this library
desc tablename; view the detailed information of a table, including column names.