Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Centos7 installs single-node mysql (source package installation)

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. Check whether the following package is installed, and uninstall if it is installed.

# rpm -qa | grep mariadb

# rpm -qa | grep postfix

# rpm -ev postfix-2.10.1-6.el7.x86_64

# rpm -ev mariadb-libs-5.5.44-2.el7.centos.x86_64

Creating Users and Groups

# groupadd mysql

# useradd -g mysql mysql

3. Decompression

# tar -zxf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz

# mv mysql-5.7.17-linux-glibc2.5-x86_64 /usr/local/mysql

4. Modify the configuration file

# cd /usr/local/mysql/support-files

# cp my-default.cnf /etc/my.cnf

# vi /etc/my.cnf

[mysql]

default-character-set=utf8

[mysqld]

default-storage-engine=INNODB

character_set_server=utf8

pid_file=/data/mysql/mysql.pid

expire_logs_days=15

innodb_buffer_pool_size=8G

innodb_log_file_size=256M

innodb_flush_method=O_DIRECT

max_connections=500

innodb_autoextend_increment=128

basedir = /usr/local/mysql

datadir = /data/mysql/data

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

Modify file permissions

# chown -R mysql:mysql /usr/local/mysql

# mkdir -p /data/mysql/data

# chown -R mysql:mysql /data

# chown 777 /etc/my.cnf

5. Initialize the database

# cd /usr/local/mysql/bin

# ./ mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/data

6. Set the boot to start automatically

# cp mysql.server /etc/rc.d/init.d/mysqld

# chmod +x /etc/rc.d/init.d/mysqld

# chkconfig --add mysqld

7. Start and check the service

# service mysqld start

# ps -ef | grep mysql

# netstat -an | grep :3306

8. Setting environment variables

vi /etc/profile

export PATH=$PATH:/usr/local/mysql/bin

source /etc/profile

Log in and change your password

# mysql -uroot -p

The password can be viewed in the/root/.mysql_secret file

If you can't find the password, you can also configure it to skip the password and log in directly. Change the password and change it back.

The specific method is as follows:

# vi /etc/my.cnf

[mysqld]

skip-grant-tables

# service mysqld restart

mysql -uroot -p

mysql> update mysql.user set authentication_string=password ('custom password') where user ='root ';

mysql> grant all privileges on *.* to 'root'@'%' identified by 'custom password';

If there is an error:

mysql> update mysql.user set authentication_string=password ('custom password') where user ='root ';

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

mysql> SET PASSWORD = PASSWORD ('custom password');

Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;

Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report