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

Linux centos7 install mysql5

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Install mysql5 under Linux centos7

mysql installation in Linux environment

1.1 Installation Package Preparation

Linux installation mysql mainstream installation source code installation and rpm installation, this note uses rpm mode to install mysql 5.5.48.

Mysql Rpm package download address https://downloads.mysql.com/archives/community/, download mysql-server.rpm and mysql-client.rpm two installation packages.

Linux file storage specification 3rd party installation packages are placed under/opt directory, use xftp or other remote tools to upload the downloaded rpm package to Linux/opt directory.

1.2 First of all, centos7 does not support mysql, because the charge you know, so the internal integration of mariadb, and install mysql will conflict with mariadb files, so you need to uninstall mariadb first, the following steps are to uninstall mariadb, install mysql.

Use the command to view the installed mariadb version rpm -qa| grep mariadb

uninstall mariadb using the command rpm -e --nodeps package name

To check if mysql is installed, use the command rpm -qa| grep -i mysql, if this machine has not been installed mysql will not have any information displayed

If mysql is installed on this machine, you will be prompted as follows

If mysql is already installed and needs to be uninstalled use rpm uninstall command rpm -e --nodeps installation package name

Confirm that mysql has been uninstalled

Or use the command to see if there is still mysql related installation whereis mysql

The first time you install mysql, you may get the following warning: mysql cannot be installed successfully

The reason why the installation failed is that yum installed an older version of GPG keys. You can use the--force -nodeps parameter after the installation command to skip the warning.

Alternatively, update the version of GPG keys with the command rpm --import /etc/pki/rpm-gpg/RPM.

However, my personal test cannot resolve this warning, but this warning does not affect the installation.

Install mysql-server.rpm using the command rpm -ivh mysql-server.rpm

Note the following installation tips:

Also install mysql client using command rpm -vih mysql-client.rpm

Check if the user id root exists under Linux

Check if mysql is installed successfully

Check to see if mysql user groups have been created:

Use the following two commands to verify whether mysql is successfully installed. After mysql is successfully installed, mysql and mysql groups are automatically created. Therefore, you can check whether mysql is successfully installed by using the following two commands.

cat /etc/passwd|grep mysqlcat /etc/group|grep mysql

Or use mysqladmin --version to verify that mysql is installed successfully

Use ps -ef| grep mysql View mysql process

Use service mysql start background to start mysql, use service mysql stop to stop mysql service

MySQL ROOT password settings and boot autoboot

Connect to mysql server by typing mysql directly on command line

using show databases;

Use the command/usr/bin/mysqladmin -u root password 123456 to set the login password of the root user. Type mysql and enter directly. The prompt cannot be connected to mysql. The password is set successfully.

Log in to mysql using mysql -u root -p after entering your password

To set the mysql service to boot automatically: use the commands chkconfig mysql on, and chkconfig --list| grep mysql check whether the settings are successful

Use the command ntsysv to check whether mysql boot is successful: boot from the boot to the front of the desired number

modify the configuration file

Install mysql using rpm by default. There will be default configuration files in the directory/usr/share/mysql. Copy the configuration files to the/etc directory and modify them *

Use cd /usr/share/mysql to enter the directory

The default configuration file for mysql is my-huge.cnf. The mysql version in this article is 5.5.48. The default configuration file for other mysql versions may not be my-huge.cnf.

Execute the command cp my-huge.cnf /etc/my.cnf to copy the configuration file to the/etc directory and rename it

service mysql stop service mysql start restart mysql

Modify mysql default character set mysql default character set is latin1, insert data Chinese will appear garbled characters need to be modified to utf8

View Character Set Coding show variables like 'character%'

Modify mysql character set

Use the command to edit vim /etc/my.cnf to add the following configurations to the three configurations of [client] [mysqld] [mysql] respectively. Note that if you manually enter the following configurations, make sure that the input is correct, otherwise mysql will give an error when starting.

[mysql]

default-character-set=utf8

[mysqld]

character_set_server=utf8

character_set_client=utf8

collation-server=utf8_general_ci

[client]

default-character-set=utf8

Use the command service mysql restart to restart the mysql service

After connecting to the database, check the database db01 before modifying the configuration file, and find that the character set code of db01 database is still latin1, because the modified character set is only valid for the database created later, and the modified character set of the database created is invalid.

Re-create database db02 Verify that the character set modification is valid and find that the character set has been modified to utf8

At this point Linux installation mysql 5.5.48 is also all over, I have a lot of flaws in the article, the wrong place to see the message exchange, welcome to reprint

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