How to install mysql on linux ubuntu: 1. Open the terminal and update the software package list; 2. Install MySQL through "$ sudo apt-get install mysql-server mysql-client"; 3. Log in with the root account. Can.
The operating environment of this article: ubuntu 16.04 system, mysql8, Dell G3.
How to install mysql on linux ubuntu?
【Linux】Installation and use of MySQL in Ubuntu16.04 environment
I have been writing a small function recently and want to store data in MySQL, so I have to do it locally MySQL is installed on Ubuntu 16.04 installed on the virtual machine for use. The installation and simple use process are recorded below.
1. Running environment
Ubuntu16.04
2. Open the terminal and update the software package list
$ sudo apt update
3. Install MySQL
$ sudo apt-get install mysql-server mysql-client
The following window will appear during the installation process. Here you need to fill in the password of the MySQL root account and confirm
4. Initialize the MySQL security script
$ sudo mysql_secure_installation
mysql_secure_installation will involve whether to modify the password of the root account, whether to remove anonymous users, whether to allow remote login, whether to delete the test database, etc.
5. After installation, we first log in with the root account and enter the root account password set during installation.
$ mysql -u root -p
6. Create MySQL database and user
$ create database blogdata; # 创建一个名为blogdata的数据库 $ grant all on blogdata.* to 'bloguser' identified by 'test1234'; #创建用户bloguser
$ show databases;
$ mysql -u bloguser -p blogdata
CREATE TABLE article (id INT, name VARCHAR(300), created_time DATETIME, view_num INT, com_num INT, channel VARCHAR(20), get_time DATETIME);
INSERT INTO article (id,name,created_time,view_num,com_num,channel,get_time) VALUES(1,"test","2019-11-20 10:00:00",2,1,"bky","2019-11-22 14:00:00");
## 10. Simple query
select * from article;
11. Other commands
Exit the MySQL command line:
mysql> quit
View the MySQL running status:
$ sudo systemctl status mysql.service
$ sudo systemctl stop mysql.service
$ sudo systemctl start mysql.service
$ sudo systemctl restart mysql.service
$ sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
The above is the detailed content of How to install mysql on linux ubuntu. For more information, please follow other related articles on the PHP Chinese website!