MySQL for Linux database installation process

Source: Internet
Author: User
Tags mysql client

MySQL for Linux database installation process

L installation Version: Mysql-advanced-5.6.12-linux-glibc2.5-x86_64.tar.gz, this version is a green version, just need to extract it to the relevant directory.

PS: This installation method is not a common installation method for a specific platform, and the binary file used is a compressed file with the suffix. tar.gz

Ps:mysql:http://pan.baidu.com/s/1eqjholo

1 , creating MySQL User / Account Number

[[email protected] ~]# Groupadd mysql--add group

[[email protected] ~]# useradd-m-s/bin/bash-d/home/mysql-gmysql mysql--Add user and specify user location, path, user group

[[email protected] ~]# passwd mysql--Change password

[Email protected] ~]#

2 , create a directory

L for good management, install MySQL in a fixed directory/home/, rename the extracted MySQL to MySQL

[Email protected] ~]# mkdir-p/home/

[Email protected] ~]# TAR-ZXVF mysql-advanced-5.6.12-linux-glibc2.5-x86_64.tar.gz

[Email protected] ~]# MV Mysql-advanced-5.6.12-linux-glibc2.5-x86_64/home/mysql

L Create a logs directory below the home directory where the user holds the MySQL log file.

[Email protected] mysql]# mkdir logs

L Authorization of related catalogue

[[Email protected] ~] #cd/home/mysql/

[[email protected] MySQL] #chown-R Root

[[email protected] MySQL] #chown-r MySQL Data

[[email protected] MySQL] #chgrp-R MySQL

3 , initialize the database

MySQL's original configuration file can be found in support-files

MY-DEFAULT.CNF, this is the MySQL parameter file, usually this file will be renamed to MY.CNF, put into the/home/mysql directory.

[email protected] support-files]# CP my-default.cnf-c/HOME/MYSQL/MY.CNF

L Modify the My.cnf file and add the following content:

[Mysqld]
Basedir =/home/mysql--Install root directory
DataDir =/home/mysql/data--Database storage path
Socket =/tmp/mysql.sock
Log-error=/home/mysql/mysql_error.log
Skip-name-resolve
Character_set_server=utf8
#init_connect = ' Set names UTF8 '

Sql_mode=no_engine_substitution,strict_trans_tables

Max_allowed_packet = 32M
Table_open_cache = 1024
Sort_buffer_size = 4M
Join_buffer_size = 2M
Net_buffer_length = 8M
Read_buffer_size = 4M
Read_rnd_buffer_size = 8M
Thread_cache_size = 300
Query_cache_size = 1024M
Query_cache_limit = 2M
Thread_concurrency = 8
Wait_timeout = 315360000
Max_connections = 300
max_connect_errors=1844674407370954751
Max_connect_errors = 10000
#event_scheduler =1

#innodb_log_file_size =256m
Innodb_buffer_pool_size = 4094M
Innodb_additional_mem_pool_size = 32M
Innodb_log_file_size = 1024M
Innodb_log_files_in_group = 2
Innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 2
Innodb_lock_wait_timeout = 50
Innodb_thread_concurrency=8
#innodb_sort_buffer_size =32m
innodb_open_files=4096
innodb_write_io_threads=2
innodb_read_io_threads=2
innodb_max_dirty_pages_pct = 90
Innodb_file_per_table=1

[Client]
Socket=/tmp/mysql.sock
Default-character-set=utf8

L Enter the script directory

[Email protected] mysql]# CD scripts/

[Email protected] scripts]#./mysql_install_db--defaults-file=/home/mysql/my.cnf--datadir=/home/mysql/data-- Basedir=/home/mysql

Note: This place must specify the path of the database file storage, or the subsequent startup process will be an error.

4 , configuration file modification,

L Modify the Environment configuration, modify the add in. bash_profile


Path= $PATH: $HOME/bin:/home/mysql/bin

Export path= $PATH:/home/mysql/bin

L Add the following lines to the/etc/security/limits.conf to modify the account resource limits (if no need is not required)

MySQL Soft nproc 65536
MySQL Hard Nproc 65536
MySQL Soft nofile 65536
MySQL Hard nofile 65536

• Restart scripts and view changes after modification

[Email protected] java]$ source/etc/security/limits.conf

[Email protected] java]$ ulimit-a

Open files (-N) 65536

MAX User Processes (-u) 65536

PS: If you need to know more about Linux Ulimit, please refer to: http://blog.csdn.net/wanghai__/article/details/6332540

L Mysql.server, this file is a MySQL service file, usually this file is renamed to MySQL or mysqld, placed under the/etc/rc.d/init.d/directory

[Email protected] support-files]# Cpmysql.server/etc/rc.d/init.d/mysqld

Edit the file, modify the directory for the correct directory, as follows

Basedir=/home/mysql

Datadir=/home/mysql/data

This setting can then be used to start the shutdown of the MySQL service with service mysqld Start/stop.

Legacy issue: Because the path and file name of the configuration file have been modified, the profile path specified in the service file mysqld is still/etc/my.cnf, so you start and close the MySQL data with the service mysqld start/ Stop will have a problem (cannot read the correct parameter file)

5 , database service startup

Go to MySQL's home directory:

[[Email Protected]mysql]#.bin/mysqld_safe--defaults-file=/home/mysql/my.cnf--user=mysql&--Initialize database

After you start the service, you can view the directory structure of the database by using the PS command:

[Email protected] mysql01]# Ps-ef | grep MySQL

6 , database User Configuration

1) root User settings password

[[email protected] ~]# mysqladmin-u rootpassword ' MySQL '

2) Data Login

[Email protected] ~]# mysql-u root-p

Enter Password:

Welcome to the MySQL Monitor. Commands End With; or \g.

Your MySQL Connection ID is 4

Server version:5.1.48-community mysqlcommunity Server (GPL)

Copyright (c), Oracle And/orits affiliates. All rights reserved.

This software comes with absolutely nowarranty. This is the free software,

And you is welcome to modify Andredistribute it under the GPL v2 license

Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.

Mysql>

3) Configure the remote access permission for the root user, which can be connected via the client after Setup.

Mysql> GRANT All privileges on * * to ' root ' @ '% ' identified by ' illusioned ';

Query OK, 0 rows Affected (0.00 sec)

mysql> flush Privileges;

Query OK, 0 rows Affected (0.00 sec)

4) Add a new user to develop and give all permissions

Mysql> Grant all privileges on * * to[email protected] "%" identified by ' 123456 ' with GRANT OPTION;

Telnet permissions to new users

Mysql> grant all privileges on *.*to ' develop ' @ '% ' identifiedby ' 123456 ';(give remote operation permission)

Give new users local logon operation permissions

Mysql> GRANT all privileges on *.*to ' develop ' @ ' localhost ' identifiedby ' 123456 '; (Give local operations permission)

7 , setting and modification of parameters

There are two ways to modify and set the parameters of MySQL. First, by modifying the parameter file (MASTER.CNF), the parameter file is sometimes incomplete, the parameters that do not exist need to be added manually, but the parameter file may need to be restarted for the database to take effect, and the second is to complete the SET command, this situation does not require a restart.

Check the parameters by show Variableslike ' ... ' to see the following:

Mysql> show VARIABLES like ' character% ';

Some of the parameters are viewed and set as follows:

1) Turn on event scheduling

Set global Event_scheduler = 1;

2) See if partitioning is supported

Show variables like '%partition% ';

Some versions cannot view the partition with this parameter, use the following statement.

Show plugins;

To confirm whether the partition is an active state

| Partition | ACTIVE | STORAGE ENGINE | NULL | Proprietary |
3) View Schedule Task creation

Show events;

4) View Character set

Show variables like '%character% ';

Temporarily change character set

Set Names UTF8

5) View MySQL open files limit

Show variables like ' open% ';

Show global status like ' open_% ';

8. Questions

Question one:

[ERROR] Fatal Error:can ' t open and lock privilegetables:table ' mysql.user ' doesn ' t exist

FATAL error:could not find./bin/my_print_defaults

Cause: The default path is used to install the database when initializing the database, but the configuration file has actually modified the associated database file path.

WORKAROUND: If you change the directory where the data files are stored, be sure to specify the DataDir location

[Email protected] scripts]#/mysql_install_db--user=mysql--basedir=/data/mysql--datadir=/data/mysql/data &

Question two:

ERROR 2002 (HY000): Can ' t connect to local MySQL serverthrough socket '/var/lib/mysql/mysql.sock ' (111)

Cause: Some MySQL installation will mysql.sock in the/var/lib/mysql without the following, some MySQL placed under/tmp. Since a MySQL client has been installed on the previous machine, the Mysql.sock location is different.

Workaround: Specify the path to the Mysql.sock parameter in the parameter file MY.CNF.

[Mysqld]
Socket=/var/lib/mysql.sock

Question three:

Error: ' Access denied for user ' root ' @ ' localhost ' (usingpassword:no) '

Cause of the problem: the possible cause is that the database was installed, the root password was not set, or some improper operation was caused.

Workaround: Execute the following statement.

Use the KILL statement to first stop the database service, execute,

[Email protected] Mysql01]#.bin/mysqld_safe./bin/mysqld_safe--user=mysql--skip-grant-tables--skip-networking &

[[email protected] mysql01]#.mysql-u root

mysql> use MySQL

mysql> Update user set Password=password (cattsoft) where user= ' root '

mysql> flush Privileges;

Mysql> quit;

Restarting the database service

Question four:

[ERROR] Plugin ' InnoDB ' init function returned error.

Cause: Due to a number of other reasons, such as the lack of parameters during the initialization of the database.

Workaround: Delete the Ib_logfile0 and ib_logfile1 two files in the MySQL directory.

MySQL for Linux database installation process

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.