Ubuntu installation MySQL Database

Source: Internet
Author: User

The installation of MySQL on Ubuntu is very simple and requires just a few commands to complete.
sudo apt-get install mysql-server (uninstall is sudo aptitude purge mysql-server but will be installed sudo apt-get install aptitude to use)


Ubuntu 16.04 installation using MySQL

MySQL is a popular database system and the following records the installation of MySQL steps on Ubuntu 16.04.

If you are using a previous version of Ubuntu 16.04, you can look here: Ubuntu 14.04/15.10 upgrade to Ubuntu 16.04 LTS.


Update the package list before installing:


$ sudo apt update
1
$ sudo apt update
To install MySQL on Ubuntu 16.04:


$ sudo apt install mysql-server mysql-client
1
$ sudo apt install mysql-server mysql-client
You need to enter the MySQL administrator user (root) password during the installation process
Run the MySQL initialization security script:

$ sudo mysql_secure_installation
Mysql_secure_installation Script settings: Change the root password, remove the anonymous user from MySQL, disable root telnet, delete the test database. Use these options to improve the security of MySQL.
MySQL Database basic use

Log in with the root user:


$ mysql-u Root-p

Enter the root password:
Mysql-h Localhost-u Root-p
-U indicates the user name to select login
-P indicates login user password
-H Login Host name

To create a MySQL database and users:


mysql> CREATE DATABASE Snailblog;

The above command creates a database named Snailblog.

Create a user and use the Snailblog database:


Mysql> Grant all on snailblog.* to ' Man_user ' identified by ' test1234 ';
Sign in with a new user:


$ mysql-u man_user-p Snailblog

Screen Shot 2016-04-02 at 09.25.53

To create a table:

mysql> CREATE TABLE User (id INT, name varchar), email varchar (20));
Insert Record:

Mysql> INSERT into User (Id,name,email) VALUES (1, "Bar", "[email protected]");
Mysql> INSERT into User (Id,name,email) VALUES (2, "foo", "[email protected]");
Mysql> INSERT into User (Id,name,email) VALUES (3, "Cat", "[email protected]");
Simple query:

Mysql> SELECT * from user;
Screen Shot 2016-04-02 at 09.31.07

To exit the MySQL command line:


Mysql> quit
Bye
1

To stop the MySQL database service:


$ sudo systemctl stop Mysql.service

To start the MySQL database service:


$ sudo systemctl start mysql.service

To restart the MySQL database service:


$ sudo systemctl restart Mysql.service
To view MySQL running status:

$ sudo systemctl status Mysql.service

MySQL configuration file:


$ sudo vim/etc/mysql/mysql.conf.d/mysqld.cnf
MySQL 5.6 Document: http://dev.mysql.com/doc/refman/5.6/en/

Ubuntu installation MySQL database

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.