In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
1. Turn off the mysql service
# service mysqld stop
two。 Check whether there is a rpm package. If you have not installed mysql with rpm, there should be no residue. If so, delete it.
Check syntax: rpm-qa | grep-I mysql
Delete syntax: rpm-e
If you encounter dependencies and cannot be deleted, use rpm-e-- nodeps to delete the rpm package without checking for dependencies.
3. Check whether the mysql file is installed through the find command and delete it.
Check the syntax: find /-name mysql
Delete syntax: rm-rf directory files (or files)
* (2) create mysql groups and users *
1. Violently delete mysql users
Delete syntax: userdel-r-f mysql (if not, it will prompt you that mysql does not exist, never mind)
two。 Add grouping
Add syntax: groupadd mysql
3. Add mysql user
Add syntax: useradd-g mysql mysql
* (3) decompress the tar package *
1. Cd to mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz directory
two。 Extract the tar package
Decompression syntax: tar zxvf mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz
An extra mysql-5.7.12-linux-glibc2.5-x86_64 file is created after decompression.
Copy this file to your favorite directory and rename it to mysql. Please wait patiently when copying.
After copying, cd to the mysql directory and create a new folder for data.
Copy syntax: cp-r mysql-5.7.12-linux-glibc2.5-x86_64 / usr/local/mysql
New file syntax: mkdir data
Chmod 770 data
Create a new data folder in / usr/local/mysql and modify the permissions to 770 (drwxrwx---.):
[wangh@HavGO mysql] $sudo mkdir data [wangh@HavGO mysql] $sudo chmod 770 data
Set the user of / usr/local/mysql to mysql and the user group to mysql:
[wangh@HavGO ~] $cd / usr/local/ [wangh@HavGO local] $sudo chown-R mysql:mysql mysql
Go to the / usr/local/mysql folder and execute the command:
[wangh@HavGO mysql] $sudo bin/mysqld-initialize-user=mysql-basedir=/usr/local/mysql-datadir=/usr/local/mysql/data
This command means to initialize and establish the user, mysql directory and data directory (data created in step 3)
After the execution, we get an initial mysql password. We need to save it first and use it later when logging in to mysql for the first time.
2018-06-30T07:40:21.663544Z 1 [Note] A temporary password is generated for root@localhost: 0hl..Ult.usK
A temporary password is generated for root@localhost: 0hl..Ult.usK
0hl..Ult.usK
When the above is over, execute the command:
[wangh@HavGO mysql] $sudo bin/mysql_ssl_rsa_setup-- basedir=/usr/local/mysql-- datadir=/usr/local/mysql/data
This command sets the SSL secure connection mysql (RSA encryption), and specifies the mysql directory and data directory
Create a new mysql log folder in / var/log/ to store the mysql running log:
[wangh@HavGO mysql] $cd / var/log [wangh@HavGO log] $sudo mkdir mysql
Execute the following command in the / usr/local/mysql folder:
[wangh@HavGO mysql] $sudo bin/mysqld_safe-user=mysql-basedir=/usr/local/mysql/-datadir=/usr/local/mysql/data &
Press enter again to let the command run in the background
Mysqld_safe script function self-Baidu
Add mysql to / etc/init.d startup boot:
[wangh@HavGO mysql] $sudo cp support-files/mysql.server / etc/init.d/mysql
Configuration / etc/my.cnf (my.cnf is the configuration file for mysql)
[wangh@HavGO mysql] $vim / etc/my.cnf
Modify the configuration, as shown below:
[mysqld] # set mysql installation directory basedir=/usr/local/mysql # set mysql database data storage directory datadir=/usr/local/mysql/data # the character set used by the server defaults to the 8-bit encoded latin1 character set character-set-server=utf8 socket=/tmp/mysql.sock # socket=/var/lib/mysql/mysql.sock user=mysql [mysql-safe] log-error=/var/log/mysql/mysqld.log pid-file=/var/run/mysqld/mysqld.pid
Other settings can be matched or not.
# set mysql client default character set default-character-set=utf8 socket=/var/lib/mysql/mysql.sock [mysqld] skip-name-resolve # set 3306 port port = 3306 # allow maximum number of connections the default storage engine default-storage-engine=INNODB lower_case_table_names=1 max_allowed_packet=16M# that will be used when max_connections=200# creates a new table can be uncommented if you forget your password and log in # skip-grant-tables without a password
Configure environment variables
[wangh@HavGO mysql] $vim / etc/profile
Add the following:
Export MYSQL_HOME= "/ usr/local/mysql" export PATH= "$PATH:$MYSQL_HOME/bin"
After adding, save and exit, let the environment variable take effect immediately:
[wangh@HavGO mysql] $source / etc/profile
Now that mysql is installed, start the mysql service:
[wangh@HavGO etc] $sudo service mysql start
Shows that the startup was successful.
If in step 2, the mysql folder is not named "mysql", mysqld_safe will report an error showing "mysqld_safe The file / usr/local/mysql/bin/mysqld"
Does not exist or is not executable. "
Because the default mysql path of the mysqld_safe script is / usr/local/mysql, there are two solutions: change all / usr/local/mysql directories in mysqld_safe to your actual installation directory
Or link your actual installation directory to / usr/local/mysql
Mkdir / var/lib/mysql mysql_install_db-user=mysql-ldata=/var/lib/mysql/
After the mysql service starts, type the command to enter mysql, and the password is the initial password obtained previously.
[wangh@HavGO etc] $mysql-u root-p
Enter the initial password and enter
Set the new password to: jkl12345784
Log in with the new password again and you can use mysql.
Change the root password immediately after logging in:
Mysql > alter user 'root'@'localhost' identified by' admin'; Query OK, 0 rows affected (0.00 sec)
Where your_password is the new password you set. The new password should be a strong password, requiring the password to contain uppercase and lowercase letters, numbers and punctuation, with a length of more than 6 digits.
Grant all privileges on *. * to 'root'@'%'identified by' admin' with grant option; flush privileges ps aux | grep httpd
Summary
The above is the detailed explanation of the tutorial of installing mysql under Linux introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply you in time. Thank you very much for your support to the website!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.