Installation of MySQL Server 5.6 on Ubuntu
MySQL is very popular database system for a small to medium size web project. It is developed, distributed, and supported by Oracle Corporation. We can run MySQL on various platforms like Window,Linux,Unix. It is full-featured relational database management system (RDBMS).In this article I will show you the installation of MySQL server 5.6 on Ubuntu.
Below are the steps to install MySQL Server on Ubuntu.
|
1
2
3
|
devops@devopsservice:~$ sudo apt-get install python-software-properties -y
|
Add MySQL Repository
|
1
2
3
|
devops@devopsservice:~$ sudo apt-add-repository ppa:ondrej/mysql-5.6 -y
|
|
1
2
3
|
devops@devopsservice:~$ sudo apt-get update -y
|
Install MySQL Server package using apt-get
|
1
2
3
|
devops@devopsservice:~$ sudo apt-get install mysql-server -y
|
During Installation it will ask you to provide root user password of MySQL.
– Check Installed Version of MySQL
|
1
2
3
|
devops@devopsservice:~$ mysql --version
|
– Login into MySQL Server using command line
After MySQL server installation finish, it wil start MySQL service automatically.
|
1
2
3
|
devops@devopsservice:~$ mysql -u root -p
|
– MySQL Service related command
Check status of MySQL Service
|
1
2
3
|
devops@devopsservice:~$ sudo /etc/init.d/mysql status
|
Stop MySQL Service
|
1
2
3
|
devops@devopsservice:~$ sudo /etc/init.d/mysql stop
|
Start MySQL Service
|
1
2
3
|
devops@devopsservice:~$ sudo /etc/init.d/mysql start
|
Restart MySQL Service
|
1
2
3
|
devops@devopsservice:~$ sudo /etc/init.d/mysql restart
|
Below are the list of user related command for MySQL
– Change the password of MySQL user.
You can change the MySQL password using two ways. One is using mysqladmin command and other way is after login to mysql prompt.
1) Change the password using mysqladmin command
Syntax: mysqladmin -u username -p’oldpassword’ password “newpassword”
Example:
|
1
2
3
|
devops@devopsservice:~$ mysqladmin -u root -p'Devops@321' password "Devops@654"
|
2) Change the password after login to mysql prompt.
Login to MySQL server
|
1
2
3
|
devops@devopsservice:~$ mysql -u root -p
|
Switch to mysql database.
|
1
2
3
|
mysql> use mysql;
|
update mysql root user password
|
1
2
3
|
mysql> update user set password=PASSWORD("Devops@987") where User='root';
|
Reload the privileges
|
1
2
3
|
mysql> flush privileges;
|
– Create User
We will create user devops with password Devops@123
|
1
2
3
4
|
mysql> CREATE USER 'support'@'localhost' IDENTIFIED BY 'Devops@123';
Query OK, 0 rows affected (0.08 sec)
|
Provide access on all the databases to user devops
|
1
2
3
4
|
mysql> GRANT ALL PRIVILEGES ON *.* TO 'support'@'localhost';
Query OK, 0 rows affected (0.00 sec)
|
– View a List of MySQL Users
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
mysql> SELECT User,Host FROM mysql.user;
+------------------+-----------+
| User | Host |
+------------------+-----------+
| root | 127.0.0.1 |
| root | ::1 |
| root | devops |
| debian-sys-maint | localhost |
| support | localhost |
| root | localhost |
| wordpressuser | localhost |
+------------------+-----------+
7 rows in set (0.00 sec)
|
Thanks for reading. Do let us know if you have any feedback/suggestions.
Let us know if you want us to write us on any particular topic. We will try our best.
If you want to install MySQL server 5.7 on Ubuntu the refer the link Installation of MySQL Server 5.7 on Ubuntu 14.04.

浙公网安备 33010602011771号