Задачка очень простая: как поставить MySQL на CentOS.

Пошаговая инструкция для CentOS 6.5

Установка:

yum -y install mysql-server

Редактируем конфиг

mcedit /etc/my.cnf

1
2
3
4
5
6
7
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# добавим это:
bind-address=127.0.0.1
character-set-server=utf8

Запускаем БД

/etc/init.d/mysqld start 

1
2
3
4
5
6
7
8
9
10
11
12
Initializing MySQL database:  WARNING: The host 'wikiadmin.net' could not be looked up with resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
Installing MySQL system tables...
OK
Filling help tables...
OK
...
Starting mysqld:                      [  OK  ]

Ставим в автозагрузку:

chkconfig mysqld on 

Теперь добавим немного безопасности. Шучу, просто удалим лишнее:

mysql_secure_installation 

Увидим это:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
...
Enter current password for root (enter for none): #вводим пароль, если задали. Если нет - просто Enter
OK, successfully used password, moving on...

Set root password? [Y/n] y # жмём Y и задаём пароль для root базы данных
New password: # вводим новый пасс
Re-enter new password: #повторим ввод
... Success! #атож!

Remove anonymous users? [Y/n] y #да, удаляем анонимуса
 ... Success!

Disallow root login remotely? [Y/n] y #да, запрещаем root конектится с других хостов
 ... Success!

Remove test database and access to it? [Y/n] y #да, удаляем тестовую базу
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reload privilege tables now? [Y/n] y #да, перегрузить привелегии
 ... Success!

All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!

Пробуем подключится

mysql -u root -p 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 2.1.1 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement

mysql> show databases; #смотрим какие есть у нас базы. Test быть не должно

+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
+--------------------+
2 rows in set (0.00 sec)

mysql> exit #выходим

Bye

Пошаговая инструкция для CentOS 7

Устанавливаем

yum -y install mariadb-server

Добавим данные про UTF-8

mcedit /etc/my.cnf.d/server.cnf

в секцию

1
2
3
[mysqld]
...
character-set-server=utf8 # 13 строчка

Запускаем сервис

systemctl start mariadb 

Добавляем в автозагрузку

systemctl enable mariadb 

Увидим это:

ln -s '/usr/lib/systemd/system/mariadb.service' '/etc/systemd/system/multi-user.target.wants/mariadb.service'

Далее рекомендую так же как и примером выше, пройти команду

mysql_secure_installation


См. так же:

 MySQL  MySQL Бэкап и восстановление баз данных