"MySQL" Linux installation MySQL

Source: Internet
Author: User
Tags chmod deprecated rollback

Installation environment: System is Red Hat Enterprise Linux Server Release 6.6

Installation software: mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz

1. Download

: Http://dev.mysql.com/downloads/mysql/5.6.html#downloads

Download version: I choose here 5.6.33, General edition, Linux under 64-bit

You can also directly copy the 64-bit, download by command: wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz

2. Decompression

1

2

3

4

#解压

TAR-ZXVF mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz

#复制解压后的mysql目录

Cp-r mysql-5.6.33-linux-glibc2.5-x86_64/*/usr/local/mysql

After #或者 decompression, change to the MySQL directory name and then copy or move to/usr/local/

MV Mysql-5.6.33-linux-glibc2.5-x86_64 MySQL

Cp-r mysql/usr/local

3. Adding user groups and users

1

2

3

4

#添加用户组

Groupadd MySQL

#添加用户mysql to the user group MySQL

Useradd-r-G MySQL MySQL

# * The Useradd-r parameter indicates that the MySQL user is a system user and cannot be used to log on to the system.

# * The useradd-g parameter means to add the MySQL user to the MySQL user group.

4. Installation

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21st

22

23

24

25

26

27

28

29

30

cd/usr/local/mysql/

mkdir./data/mysql (note; database warehouse storage location specified to be customized, some can be ignored)

Chown-r Mysql:mysql./

# Execute the mysql_install_db script, initialize the data directory in MySQL and create some system tables.

./scripts/mysql_install_db--user=mysql--datadir=/usr/local/mysql/data/mysql

############ #此为5. Installation instructions before and after version 7, here with 5.6 so no need to consider the start # # #

mysql5.7 executes the mysql_install_db script, initializes the data directory in MySQL, and creates some system tables.

bin/mysql_install_db--user=mysql

Error:

2016-07-15 14:50:14 [WARNING] mysql_install_db is deprecated. Consider switching to mysqld--initialize

2016-07-15 14:50:14 [ERROR] The data directory needs to be specified.

The data directory needs to be specified, note that the MySQL service process MYSQLD runtime accesses the data directory, so it must be executed by the user who started the mysqld process (that is, the MySQL user we set up earlier), or by root, but with the parameters--user= Mysql.

There is also a warning message saying that the mysql_install_db command is deprecated and it is recommended that you switch to the mysqld--initialize command

Note:

mysql5.7 and previous versions, a lot of information is this command:. /scripts/mysql_install_db--user=mysql, while mysql5.7 's mysql_install_db command is in the bin directory and is recommended with the Mysqld--initialize command

mysql5.7 before version Initialization configuration Table command:

script/mysql_install_db--user=mysql--basedir=/ultrapower/test/mysql--datadir=/ultrapower/test/mysql/data/

#--user start MySQL user

#--basedir MySQL installation directory

#--datadir MySQL Data Warehouse directory

############ #此为5. Installation instructions before and after version 7, here with 5.6 so no need to consider the end # # #

# All files in the mysql/directory except the data/directory are changed back to the root user, and the MySQL user only needs to be the owner of all files in the mysql/data/directory.

Chown-r Root.

Chown-r MySQL Data

# Copy the configuration file (no action if/etc/my.cnf already exists)

CP SUPPORT-FILES/MY-DEFAULT.CNF/ETC/MY.CNF

Check the configuration (as normal, Basedir and DataDir are configured correctly, the socket is not specified in the/tmp/path, otherwise you need to configure TMP permissions, Log-error customization, pid-file as follows)

#/support-files/mysql.server Copy and rename to/etc/init.d/mysql and set run permissions so you can start/stop services using the service MySQL command, otherwise you can only use {mysql}/bin/ Mysqld_safe & command to start the service

CP Support-files/mysql.server/etc/init.d/mysql

# Set Run permissions

chmod +x/etc/init.d/mysql

#检查修改启动脚本

Vi/etc/init.d/mysql

#修改项:

basedir=/usr/local/mysql/

Datadir=/usr/local/mysql/data/mysql

#把mysql注册为开机启动的服务

Chkconfig--add MySQL

Chkconfig--list MySQL

#加入环境变量, edit the/etc/profile so that you can use MySQL command from anywhere.

Export path= $PATH:/usr/local/mysql/bin

Source/etc/profile

#启动服务或如命令

Service mysqld Start

#测试连接

./mysql/bin/mysql-uroot

#启动mysql

Service mysqld Start

#关闭mysql

Service Mysqld Stop

#查看运行状态

Service MYSQLD Status

5. Error

5.1 SQLyog 1130 error when connecting remotely, due to no user rights issue for remote connection (recommended 2)

Resolution 1: Change the ' MySQL ' database ' user ' table ' host ' entry from ' localhost ' to '% '.

Use MySQL;

Select ' Host ' from user where user= ' root ';

Update user Set host = '% ' where user = ' root ';

Flush privileges;

Resolution 2: Direct authorization

GRANT all privileges on * * to ' root ' @ '% ' identified by PASSWORD ' *81f5e21e35407d884a6cd4a731aebfb6af209e1b ' with GRANT OP tion;

5.2 Some hints when initializing

./scripts/mysql_install_db.
Description: At the end of initialization there will be some configuration file hints or root user initial password, please read.

5.3 Client remote connection mysql error 2003 cant connect to MySQL 10060/10061 workaround

    
Method: 1. Make sure the MySQL service is started: service MySQL status

2. Try to ping the destination IP on the command line at the end of the installed SQLyog to make sure that you can ping the

3. Check the MySQL user name and permissions on the server that needs to be connected to ensure that the user name and password entered by SQLyog are correct

4. Check user permissions after logging on to MySQL server that requires a connection: show grants;

5. Remember to turn off the firewall

6. Open the/etc/my.cnf file, bind-address = ******** A sentence preceded by #, comment out

7. Restart the MySQL service

6. Other

6.1 Configuring Environment variables

Vi/etc/profile

Add the following:

MYSQL =/usr/local/mysql/bin

Export MYSQL

7, error (can refer to)

Errors encountered during the MySQL installation:

Start MySQL

Bin/mysqld_safe--user=mysql &

[Email protected]mysql]# Bin/mysqld_safe &

[1] 13863

[Email protected]mysql]# bin/mysqld_safe:line 541:/ultrapowewr/test/mysql/data/mysqld_safe.pid: no file or directory

awk: (filename=-fnr=1) Warning:error writing standard output (disconnected pipe)

2016-07-15t07:57:05.782967zmysqld_safe Logging to '/ultrapowewr/test/mysql/data/rhel5-32.err '.

Touch: Unable to touch "/ultrapowewr/test/mysql/data/rhel5-32.err": No file or directory

CHMOD: Unable to access "/ultrapowewr/test/mysql/data/rhel5-32.err": No file or directory

Touch: Unable to touch "/ultrapowewr/test/mysql/data/rhel5-32.err": No file or directory

Chown: Unable to access "/ultrapowewr/test/mysql/data/rhel5-32.err": No file or directory

2016-07-15t07:57:05.877234zmysqld_safe starting mysqld daemon with databases From/ultrapowewr/test/mysql/data

Bin/mysqld_safe:line 135:/ultrapowewr/test/mysql/data/rhel5-32.err: No file or directory

Bin/mysqld_safe:line 169:/ultrapowewr/test/mysql/data/rhel5-32.err: No file or directory

Touch: Unable to touch "/ultrapowewr/test/mysql/data/rhel5-32.err": No file or directory

Chown: Unable to access "/ultrapowewr/test/mysql/data/rhel5-32.err": No file or directory

CHMOD: Unable to access "/ultrapowewr/test/mysql/data/rhel5-32.err": No file or directory

2016-07-15t07:57:05.923131zmysqld_safe mysqld from PID File/ultrapowewr/test/mysql/data/rhel5-32.pid ended

Bin/mysqld_safe:line 135:/ultrapowewr/test/mysql/data/rhel5-32.err: No file or directory

[[Email protected]mysql]# service MySQL Restart

MySQL server Pidfile could not being found! Failed

/etc/init.d/mysql:line 276:CD:/ultrapowewr/test/mysql: No file or directory

Startingmysqlcouldn ' t find MySQL server (/ultrapowewr/test[failed]/bin/mysqld_safe)

This error is due to an error in configuring the Basedir path in/ETC/MY.CNF.

*************************************************************************************************************** **********************************

Executive Mysql-uroot-p

Error: Error 2002 (HY000): Can ' t connect to local MySQL server through socket '/tmp/mysql.sock ' (111)

View Lessdata/rhel5-32.err

Discovery Log Output:

2016-07-15t08:13:31.786920z0 [Note]/ultrapower/test/mysql/bin/mysqld:ready for connections.

Version: ' 5.7.13 ' socket: '/temp/mysql.sock ' port:3306 mysql Community Server (GPL)

View/ETC/MY.CNF, Socket configuration:

# These arecommonly set, remove the # and set as required.

Basedir =/ultrapower/test/mysql

DataDir =/ultrapower/test/mysql/data

Port = 3306

# server_id = ...

Socket =/tmp/mysql.sock

Socket file directory is not the same as/temp/mysql.sock and error prompts,

#由上可知my. CNF is defined in the/tmp directory, and the error is in the/temp/mysql.sock/directory

#也就是说mysqld已经声称了正确的sock文件, but the client connection or the initial directory to find the sock file

It should be because, without the temp directory, MySQL is not automatically created and cannot be found

*************************************************************************************************************** **********************************

Error: The serverquit without updating PID file [failed]local/mysql/data/rhel5-32.pi

Start MySQL service times as On error, view MySQL log discovery

[Plain] View plain copy

2016-07-26t02:07:28.134232z 0 [note]innodb:highest Supported file format is Barracuda.

2016-07-26t02:07:28.172866z 0 [note]innodb:creating shared tablespace for temporary tables

2016-07-26t02:07:28.172990z 0 [note]innodb:setting file './ibtmp1 ' size to [MB]. Physically writing the filefull; Please wait ...

2016-07-26t02:07:28.244892z 0 [note]innodb:file './ibtmp1 ' size is now.

2016-07-26t02:07:28.252257z 0 [note]innodb:96 Redo rollback segment (s) found. Redo rollback Segment (s) areactive.

2016-07-26t02:07:28.252344z 0 [note]innodb:32 non-redo rollback segment (s) is active.

2016-07-26t02:07:28.253779z 0 [note]innodb:waiting for purge to start

2016-07-26t02:07:28.305124z 0 [Note] innodb:5.7.13 started; Log sequence Number 2523957

2016-07-26t02:07:28.306232z 0 [note]innodb:loading buffer pool (s) from/usr/local/mysql/data/ib_buffer_pool

2016-07-26t02:07:28.307231z 0 [Note] Plugin ' federated ' is disabled.

2016-07-26t02:07:28.315654z 0 [warning]failed to set up SSL because of the following SSL library ERROR:SSL context IsNot Usable without certificate and private key

2016-07-26t02:07:28.315736z 0 [Note] serverhostname (bind-address): ' * '; port:3306

2016-07-26t02:07:28.315825z 0 [Note] ipv6is available.

2016-07-26t02:07:28.315860z 0 [Note]-':: ' resolves to ':: ';

2016-07-26t02:07:28.316013z 0 [Note] ServerSocket created on IP: ':: '.

2016-07-26t02:07:28.316099z 0 [ERROR] couldnot create UNIX socket lock File/usr/local/mysql/tmp/mysql.sock.lock.

2016-07-26t02:07:28.316115z 0 [error]unable to setup UNIX socket lock file.

2016-07-26t02:07:28.316128z 0 [error]aborting

Cannot create a Mysql.sock.lock file, possibly a problem with insufficient permissions for the TMP directory or directory not present

Execute Chown-rmysql:mysql tmp, and then start the MySQL service to start successfully

*************************************************************************************************************** **********************************

Login Mysql,mysql-uroot-pi7ycy.:jv6yr

If error 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using password:no) because the password is not allowed to be empty

If error 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using password:yes), the password may be incorrect,

The ultimate way to stop the MySQL service, delete the data directory, re-initialize the table data, the authorized data directory to the MySQL user, with the re-generated temporary password login.

Reset password resolve MySQL for Linux error 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:yes)

Generally this error is caused by a password error, the solution is to reset the password.

Let's say we're using the root account.

1. The first step in resetting the password is to skip the MySQL password authentication process, as follows:

#vim/etc/my.cnf (Note: My.ini is modified under Windows)

Search within a document MYSQLD navigate to the [mysqld] text segment:

/mysqld (enter the command directly in the Vim edit state to search for text content)

Add "skip-grant-tables" to skip password verification on any line following [Mysqld], as shown in:

Save the document and exit:

#:wq

2. Next we need to restart MySQL:

/etc/init.d/mysqlrestart (some users may need to use/etc/init.d/mysqldrestart or service MySQL restart)

3. After rebooting, enter the./bin/mysql to enter MySQL.

Cd/usr/local/mysql

./bin/mysql

4. The next step is to use SQL to modify the root password

Mysql> Usemysql;

Mysql> UpdateUser Set Password=password ("Your new password") where user= "root";

Mysql> flushprivileges;

Mysql> quit

The root account has been reset to the new password.

5. Edit the my.cnf, remove the content you just added, and then restart MySQL. Done!

Service Mysqlrestart

There are many online solutions to this problem, many of the new contacts may be more confusing to find on their own platform my.cnf or my.ini files, if you are Linux, use the following ways to search: Whereis my

As for the Windows platform, go to the installation directory and look for My.ini.

"MySQL" Linux installation MySQL

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.