Install and use MySQL on CentOS

Install

For my VM is a new VM, so I don’t need to check the previous version.
MYSQL version is 5.7.13
CentOS version is 7

Install repository of MySQL

There are some versions for Linuxdownload
I don’t know choose which one. Just select the first one: Red Hat Enterprise Linux 7 / Oracle Linux 7 (Architecture Independent), RPM Package
Double click to install, it don’t take much time.
By the way, after install repository, if you want to check the repository, it’s at /etc/yum.repos.d

Install MYSQL server

http://dev.mysql.com/doc/refman/5.7/en/linux-installation-yum-repo.html In the terminal, just enter:
sudo yum install mysql-community-server

Change root password

As it said, after installing the MySQL server, it will create a temporary password for account ‘root’
It is in /var/log/mysqld.log
To get the password, with command:
sudo grep ‘temporary password’ /var/log/mysqld.log
log in MySQl with the password :
mysql -uroot -p
Then set your new password:
ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘MyNewPass4!’;
Attention: Don’t forget the “;” at the end.

Create Database

I think the client of MySQL is needed,at the beginning, it doesn’t matter. With command:
CREATE DATABASE dbname;
dbname is the database’s name you want.

For example,
I created a database named “demo”
CREATE DATABASE demo; Then terminal output:Query OK, 1 row affected (0.03 sec)

If you want to create a table in the new database.
You need to use it:
use demo;
Then create a table you want:
create TABLE job(id integer,name varchar(50),recipe varchar(50));

MySql workbench remote connect MySql

the user ‘root’ cannot be login when remote connect. You should create an administrator user. Then using it to login.


Allen Li

Allen Li

Just another boring, tattooed, time traveling designer.


Updated