MySQL Admin

 

Install mysql 5.7 in Ubuntu

root@ubuntu:~# sudo apt-get install mysql-server

Reading package lists… Done

Building dependency tree

Reading state information… Done

The following additional packages will be installed:

 libaio1 libhtml-template-perl mysql-client-5.7 mysql-client-core-5.7

 mysql-common mysql-server-5.7 mysql-server-core-5.7

Suggested packages:

 libipc-sharedcache-perl mailx tinyca

The following NEW packages will be installed:

 libaio1 libhtml-template-perl mysql-client-5.7 mysql-client-core-5.7

 mysql-common mysql-server mysql-server-5.7 mysql-server-core-5.7

0 upgraded, 8 newly installed, 0 to remove and 209 not upgraded.

Need to get 18.0 MB of archives.

After this operation, 160 MB of additional disk space will be used.

Do you want to continue? [Y/n] y

Get:1 //us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 mysql-common                                                                                         all 5.7.12-0ubuntu1.1 [17.0 kB]

Get:2 //us.archive.ubuntu.com/ubuntu xenial/main amd64 libaio1 amd64 0.3.11                                                                                        0-2 [6,356 B]

Get:3 //us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 mysql-client                                                                                        -core-5.7 amd64 5.7.12-0ubuntu1.1 [6,120 kB]

Get:4 //us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 mysql-client                                                                                        -5.7 amd64 5.7.12-0ubuntu1.1 [1,695 kB]

Get:5 //us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 mysql-server                                                                                        -core-5.7 amd64 5.7.12-0ubuntu1.1 [7,503 kB]

Get:6 //us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 mysql-server                                                                                        -5.7 amd64 5.7.12-0ubuntu1.1 [2,587 kB]

Get:7 //us.archive.ubuntu.com/ubuntu xenial/main amd64 libhtml-template-per                                                                                        l all 2.95-2 [60.4 kB]

Get:8 //us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 mysql-server                                                                                         all 5.7.12-0ubuntu1.1 [10.1 kB]

Fetched 18.0 MB in 1min 20s (224 kB/s)

Preconfiguring packages …

Selecting previously unselected package mysql-common.

(Reading database … 207411 files and directories currently installed.)

Preparing to unpack …/mysql-common_5.7.12-0ubuntu1.1_all.deb …

Unpacking mysql-common (5.7.12-0ubuntu1.1) …

Selecting previously unselected package libaio1:amd64.

Preparing to unpack …/libaio1_0.3.110-2_amd64.deb …

Unpacking libaio1:amd64 (0.3.110-2) …

Selecting previously unselected package mysql-client-core-5.7.

Preparing to unpack …/mysql-client-core-5.7_5.7.12-0ubuntu1.1_amd64.deb …

Unpacking mysql-client-core-5.7 (5.7.12-0ubuntu1.1) …

Selecting previously unselected package mysql-client-5.7.

Preparing to unpack …/mysql-client-5.7_5.7.12-0ubuntu1.1_amd64.deb …

Unpacking mysql-client-5.7 (5.7.12-0ubuntu1.1) …

Selecting previously unselected package mysql-server-core-5.7.

Preparing to unpack …/mysql-server-core-5.7_5.7.12-0ubuntu1.1_amd64.deb …

Unpacking mysql-server-core-5.7 (5.7.12-0ubuntu1.1) …

Processing triggers for libc-bin (2.23-0ubuntu3) …

Processing triggers for man-db (2.7.5-1) …

Setting up mysql-common (5.7.12-0ubuntu1.1) …

update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.c                                                                                        nf (my.cnf) in auto mode

Selecting previously unselected package mysql-server-5.7.

(Reading database … 207575 files and directories currently installed.)

Preparing to unpack …/mysql-server-5.7_5.7.12-0ubuntu1.1_amd64.deb …

Unpacking mysql-server-5.7 (5.7.12-0ubuntu1.1) …

Selecting previously unselected package libhtml-template-perl.

Preparing to unpack …/libhtml-template-perl_2.95-2_all.deb …

Unpacking libhtml-template-perl (2.95-2) …

Selecting previously unselected package mysql-server.

Preparing to unpack …/mysql-server_5.7.12-0ubuntu1.1_all.deb …

Unpacking mysql-server (5.7.12-0ubuntu1.1) …

Processing triggers for ureadahead (0.100.0-19) …

Processing triggers for systemd (229-4ubuntu4) …

Processing triggers for man-db (2.7.5-1) …

Setting up libaio1:amd64 (0.3.110-2) …

Setting up mysql-client-core-5.7 (5.7.12-0ubuntu1.1) …

Setting up mysql-client-5.7 (5.7.12-0ubuntu1.1) …

Setting up mysql-server-core-5.7 (5.7.12-0ubuntu1.1) …

Setting up mysql-server-5.7 (5.7.12-0ubuntu1.1) …

update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my                                                                                        .cnf) in auto mode

Setting up libhtml-template-perl (2.95-2) …

Setting up mysql-server (5.7.12-0ubuntu1.1) …

Processing triggers for libc-bin (2.23-0ubuntu3) …

Processing triggers for ureadahead (0.100.0-19) …

Processing triggers for systemd (229-4ubuntu4) …

root@ubuntu:~# sudo mysql_secure_installation

 

Securing the MySQL server deployment.

 

Enter password for user root:

 

VALIDATE PASSWORD PLUGIN can be used to test passwords

and improve security. It checks the strength of password

and allows the users to set only those passwords which are

secure enough. Would you like to setup VALIDATE PASSWORD plugin?

 

Press y|Y for Yes, any other key for No: y

 

There are three levels of password validation policy:

 

LOW    Length >= 8

MEDIUM Length >= 8, numeric, mixed case, and special characters

STRONG Length >= 8, numeric, mixed case, special characters and dictionary                                                                                                          file

 

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0

Using existing password for root.

 

Estimated strength of the password: 50

Change the password for root ? ((Press y|Y for Yes, any other key for No) : n

 

… skipping.

By default, a MySQL installation has an anonymous user,

allowing anyone to log into MySQL without having to have

a user account created for them. This is intended only for

testing, and to make the installation go a bit smoother.

You should remove them before moving into a production

environment.

 

Remove anonymous users? (Press y|Y for Yes, any other key for No) : n

 

… skipping.

 

Normally, root should only be allowed to connect from

‘localhost’. This ensures that someone cannot guess at

the root password from the network.

 

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n

 

… skipping.

By default, MySQL comes with a database named ‘test’ that

anyone can access. This is also intended only for testing,

and should be removed before moving into a production

environment.

 

Remove test database and access to it? (Press y|Y for Yes, any other key for No)                                                                                         : n

 

… skipping.

Reloading the privilege tables will ensure that all changes

made so far will take effect immediately.

 

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y

Success.

 

All done!

How to connect mysql

root@ubuntu:~# mysql -u root -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 8

Server version: 5.7.12-0ubuntu1.1 (Ubuntu)

 

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

 

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

 

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

 

mysql> show databases;

+——————–+

| Database           |

+——————–+

| information_schema |

| mysql              |

| performance_schema |

| sys                |

+——————–+

4 rows in set (0.08 sec)

 

mysql> create database mytest;

Query OK, 1 row affected (0.01 sec)

 

mysql> use mytest;

Database changed

Creating user in mysql

mysql> CREATE USER ‘finley’@’localhost’ IDENTIFIED BY ‘Bppimt@123’;

Query OK, 0 rows affected (0.00 sec)

 

mysql> GRANT ALL PRIVILEGES ON *.* TO ‘finley’@’localhost’ WITH GRANT OPTION;

Query OK, 0 rows affected (0.00 sec)

 

mysql> SHOW GRANTS FOR ‘finley’@’localhost’;

+———————————————————————–+

| Grants for finley@localhost                                           |

+———————————————————————–+

| GRANT ALL PRIVILEGES ON *.* TO ‘finley’@’localhost’ WITH GRANT OPTION |

+———————————————————————–+

1 row in set (0.01 sec)

//dev.mysql.com/doc/refman/5.7/en/adding-users.html

 

Tags :

About the Author

debasis maity

12+ years of rich experience on Database Administrations and on Infrastructure Solution Architect. AWS Certified Solution Architect and Senior Oracle DBA

0 thoughts on “MySQL Admin

Leave a Reply

Your email address will not be published. Required fields are marked *