I installed it through Yum, which is quick and easy.
1.yum install-y mysql-server Wait for installation to complete
2.chkconfig mysqld on set up MySQL service with system boot self-boot
3.[root@local ~]# chkconfig--list mysqld confirm MySQL self-booting
Mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off If 2--5 is on the status OK
4./etc/rc.d/init.d/mysqld start mysql service
when MySQL was first installed, its root user was not set to the password. Start by setting up the root password for MySQL.
5.[root@sample ~]# mysql-u root log on to the MySQL server with the root user
6.mysql> Select User,host,password from Mysql.user; View user Information
Mysql>set password for [email Protected]=password (' Enter root password here '); Set Root password
Mysql>set password for [email protected] Domain name =password (' Enter root password here ');
Mysql> Delete from mysql.user where user= '; Delete anonymous user
Mysql> exit log out of MySQL server "Test setup password is correct"
7. Log in to database, create database and user
mysql> CREATE DATABASE ' mytest ' DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
mysql> Grant all privileges the mytest.* to testuser@localhost identified by ' 123456 '; Establish a user named TestUser that has full operational permissions on the MyTest database
log in with the user you just created
8. Modify the location of the MySQL default storage database by default in:/var/lib/mysql/by directory
Modify the location of the following two items in the/ETC/MY.CNF to the new directory
Datadir=/var/data
Modify Vi/etc/rc.d/init.d/mysqld
You can restart MySQL.
Installation and configuration of MySQL under CentOS