Install mysql online on centos

Centos5.3 online installation mysql

  1. [root@sample ~]# yum -y install mysql-server ← install MySQL
    ..... slightly
    Installed: mysql-server.i386 0:4.1.20-1.RHEL4.1
    Dependency Installed: mysql.i386 0:4.1.20-1.RHEL4.1 perl-DBD-MySQL.i386 0:2.9004-3.1 perl-DBI.i386 0:1.40-8
    Complete!

Two, configuration
[ root@sample ~]# vi /etc/my.cnf ← Edit MySQL configuration file

[ mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

Default to using old password format for compatibility with mysql 3.x

clients (those using the mysqlclient10 compatibility package).

old_passwords=1 ← Find this line, add a new rule below this line to make MySQL default encoding to UTF-8
default-character-set = gbk ← add this line
Then add the following statement at the end of the configuration file:

[ mysql]
default-character-set = gbk

Three, start the MySQL service

[ root@sample ~]# chkconfig mysqld on ← Set the MySQL service to start automatically when the system starts

[ root@sample ~]# chkconfig --list mysqld ← Confirm that MySQL starts automatically
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off ← If 2--5 is on, it is OK

[ root@sample ~]# /etc/rc.d/init.d/mysqld start ← Start MySQL service

Start mysql [OK]

Note: If the execution of this part fails, it may be because there is no database file in /var/lib/mysql, it will report [Fatal error: Can't open and lock privilege tables: Table'mysql.host' doesn't exist], which is You need to execute the mysql_install_db command to be OK.

Four, MySQL root user set password
When MySQL was first installed, its root user was not given a password. First, set the MySQL root password.

[ root@sample ~]# mysql -u root ← Log in to the MySQL server as the root user
mysql> select user,host,password from mysql.user; ← View user information
mysql>set password for root@localhost=password('Fill in root password here'); ← set root password
mysql>set password for root@domain name=password('Fill in the root password here');
mysql> delete from mysql.user where user=''; ← delete anonymous users
mysql> exit ← Exit MySQL server [Test whether the set password is correct]

Five, delete the test database
mysql> show databases; ← View existing databases in the system
mysql> drop database test; ← delete the empty database named test

  1. Test MySQL. Including the establishment of new users, as well as the use of relational database operations instructions to try to create databases and data tables. Here, the newly created user takes sleinetpub as an example.

[ root@sample ~]# mysql -u root -p ← login with root by password
Enter password: ← Enter password here

mysql> grant all privileges on test.* to sleinetpub@localhost identified by'Define the password here'; ← Create a user named sleinetpub with full operation permissions on the test database
mysql> select user from mysql.user where user='sleinetpub'; ← Confirm the existence of sleinetpub user
mysql> exit ← Exit the MySQL server
[ root@sample ~]# mysql -u sleinetpub -p ← Log in to the MySQL server with the newly created sleinetpub user
Enter password: ← Enter password here
mysql> create database test; ← Create a database named test
mysql> show databases; ← View existing databases in the system
mysql> use test ← connect to the database
mysql> create table test(num int, name varchar(50)); ← Create a table in the database
mysql> show tables; ← View existing tables in the database
mysql> drop table test; ← delete table
mysql> show databases; ← View existing databases
Empty set (0.01 sec) ← Confirm that the test database has been deleted (there is a non-root user relationship, and the database named mysql cannot be seen)
mysql> exit ← Exit the MySQL server

Seven, delete the legacy users used in the test
[ root@sample ~]# mysql -u root -p ← login with root by password
Enter password: ← Enter password here
mysql> revoke all privileges on . from sleinetpub@localhost; ← cancel user sleinetpub's operation authority on the database
mysql> delete from mysql.user where user='sleinetpub' and host='localhost'; ← delete sleinetpub user
mysql> select user from mysql.user where user='sleinetpub'; ← Find user sleinetpub, confirm whether it has been deleted or not
Empty set (0.01 sec) ← Confirm that the sleinetpub user no longer exists
mysql> flush privileges; ← refresh to make the above operations take effect
mysql> exit

  1. Finally, restart the HTTP service once.

[ root@undefined /]# /etc/rc.d/init.d/mysqld stop ← Stop HTTP service
Stop mysql [OK]

[ root@undefined /]# /etc/rc.d/init.d/mysqld start ← start HTTP service
Start mysql [OK]

Recommended Posts

Install mysql online on centos
Install MySQL 8.0.16 on Linux Centos
CentOS7.2 install Mysql5.7.13
CentOS7 install MySQL
CentOS install mysql
CentOS7 install mysql
CentOS 7 install MySQL 5.6
CentOS8 install MySQL8.0
CentOS7 install mysql8
CentOS7 install MySQL8
centos 7.5 install mysql5.7.17
How to install MySQL on CentOS 8
Install MySQL on Linux CentOS7 (Windows)
Install Docker on Centos7
install LNMP on centos7.4
Install Java on Centos 7
CentOS6.5 offline install MySQL5.6.26
Install MySQL5.7 in centos7
Install mysql5.7 under CentOS7
Nodejs install on centos7
Install FFmpeg on CentOS 8
Install RabbitMQ on CentOS 7
Install Node.js on Centos
Install mysql on Ubuntu 14.04
CentOS 7.2 Yum install MySQL 5.6
Centos7 install Mysql8 tutorial
Maven install on centos7
Install MongoDB on CentOS 7
Install Surelog on CentOS8
Centos manually install mysql8
Install mysql under Centos 7
Centos7 install Mysql database
Openjdk install on centos7
Install Jenkins on centos7
Install mysql5.1 under CentOS6.5
install RabbitMQ on centos
Install RabbitMQ on CentOS 7
install Docker on centos6.5
install oracle on centos
Install Elasticsearch 6 on centos7
Install RabbitMQ on CentOS7
How to install jdk1.8.0_151 and mysql5.6.38 on centos7.2.1511
centos install mysql through yum
Install ElasticSearch 7.x on CentOS 7
Install docker transfer on Centos7
Install MySQL under Linux (CentOS 7)
Install Mysql offline on Ubuntu
Install docker on Centos system
install EPEL repo on centos
Centos6 install mysql 5.7.x series
Install Zabbix 3.4 based on CentOS 7
install virtualbox on centos server
Install Nginx server on CentOS 7
CentOS8 install MySQL8 (pro test)
1.5 Install Centos7
How to install jdk1.8 on centOS7
CentOS7 yum install and start mysql
Install JDK8 in rpm on CentOS7
How to install MySQL on Ubuntu 20.04
CentOS Yum compile and install MySQL 5.6
How to install Memcached on CentOS 8