Installation configuration MySQL

Source: Internet
Author: User

Build Configuration Musql

method One (for Ubuntu)
Compile and install MySQL

1. Installation Dependent environment
[Email protected]:~$ sudo apt-get install make cmake gcc g++ bison libncurses5-dev build-essential
Description: Make, CMake, GCC, g++, bison, Libncurses5-dev, build-essential are all dependent environments required to install the MySQL database.

2. Download the MySQL source package and unzip it
[Email protected]:~$ ls
Mysql-5.1.63.tar.gz mysql-5.1.63

3. Compile and install
[Email protected]:~$ cd mysql-5.1.63/
[Email protected]:~/mysql-5.1.63$./configure--prefix=/usr/local/mysql--enable-assembler
[Email protected]:~/mysql-5.1.63$ make
[Email protected]:~/mysql-5.1.63$ make install
Description: The compilation process to see if there is an error message, or $? To see if the return value is 0

4. Set the boot file
[Email protected]:~/mysql-5.1.63$ sudo cp/usr/local/mysql/share/mysql/my-medium.cnf/etc/my.cnf
[Email protected]:~/mysql-5.1.63$ sudo cp/usr/local/mysql/share/mysql/mysql.server/etc/init.d/mysqld

5. Add MySQL User
[email protected]:/usr/local/mysql$ sudo useradd mysql
[Email protected]:/usr/local/mysql$ sudo chown-r mysql.mysql/usr/local/mysql
[email protected]:/usr/local/mysql$ sudo chown-r mysql var

6. Turn on MySQL service
[Email protected]:/usr/local/mysql$ sudo/usr/local/mysql/bin/mysqld_safe--user=mysql &

7. View MySQL Process
[Email protected]:/usr/local/mysql$ ps-ef |grep MySQL
Root 2174 1 0 Jul18? 00:00:00/bin/sh/usr/local/mysql/bin/mysqld_safe--datadir=/usr/local/mysql/var--pid-file=/usr/local/mysql/var/ Ubuntu.pid
MySQL 2276 2174 0 Jul18? 00:00:00/usr/local/mysql/libexec/mysqld--basedir=/usr/local/mysql--datadir=/usr/local/mysql/var--user=mysql-- Log-error=/usr/local/mysql/var/ubuntu.err--pid-file=/usr/local/mysql/var/ubuntu.pid--socket=/tmp/mysql.sock-- port=3306
Ubuntu 2309 1944 0 Jul18 pts/3 00:00:00 mysql-u Root
Ubuntu 3061 1606 0 00:16 pts/2 00:00:00 grep--color=auto MySQL

8. View MySQL Port
[Email protected]:/usr/local/mysql$ sudo netstat-anptu|grep 3306
[sudo] password for ubuntu:
TCP 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2276/mysqld

9. mysql configuration files and startup files
/etc/my.cnf
/etc/init.d/mysqld

10. View the health of MySQL
[email protected]:/usr/local/mysql$ sudo service mysqld status
MYSQLD.SERVICE-LSB: Start and stop MySQL
loaded:loaded (/etc/init.d/mysqld; bad; vendor preset:enabled)
Active:active (running) since Wed 2018-07-18 22:37:10 PDT; 1h 41min ago
Docs:man:systemd-sysv-generator (8)
process:2139 execstop=/etc/init.d/mysqld Stop (code=exited, status=0/success)
process:2160 execstart=/etc/init.d/mysqld Start (code=exited, status=0/success)
CGroup:/ System.slice/mysqld.service
├─2174/bin/sh/usr/local/mysql/bin/mysqld_safe--datadir=/usr/local/mysql/var-- Pid-file=/usr/local/mysql/var/ubuntu
└─2276/usr/local/mysql/libexec/mysqld--basedir=/usr/local/mysql-- Datadir=/usr/local/mysql/var--user=mysql--log-e

Jul 22:37:09 Ubuntu systemd[1]: Starting Lsb:start and stop MySQL ...
Jul 22:37:09 Ubuntu mysqld[2160]: Starting MySQL
Jul 22:37:10 Ubuntu mysqld[2160]:. *
Jul 22:37:10 ubuntu systemd[1]: Started lsb:start and stop MySQL.

11. Log in to the MySQL database (do not use sudo authorization in front)
[Email protected]:~$ mysql-u Root
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 2
Server Version:5.1.63-log Source Distribution

Copyright (c), +, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of the Oracle Corporation and/or its
Affiliates. Other names trademarks of their respective
Owners.

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

Mysql>

Summary: After compiling the installation, if you can not start the MySQL database properly restart the system and try again, or in the configuration file to troubleshoot some configuration problems

method Two (for CentOS, Redhat)
Yum Direct installation (with Yum source configured)

1. Install MySQL
Yum Install-y mysql*

2. Start MySQL
Systemctl Start mysqld

3. View MySQL port status and process
Netstat-anptu|grep mysqld
Ps-ef |grep mysqld

4. Enter MySQL
Mysql-u root-p
Enter password
Note: The installation completed MySQL default password in/var/log/mysqld.log this file
Change Password two ways
1) ALTER USER ' root ' @ ' localhost ' identified by ' root '; #第一个root是用户名, the second root is the password set
2) Set password for [email protected] = password (' 123 '); #括号里123位设置的密码
There may be a password complex policy that requires a password to be set to meet complex requirements

Modify Password Complexity policy
#进入mysql
Mysql-u root-p
#查看一下msyql密码相关的几个全局参数:
Mysql> SELECT @ @validate_password_policy;
+----------------------------+
| @ @validate_password_policy |
+----------------------------+
| MEDIUM |
+----------------------------+
1 row in Set (0.00 sec)

mysql> SHOW VARIABLES like ' validate_password% ';
+--------------------------------------+--------+
| variable_name | Value |
+--------------------------------------+--------+
| Validate_password_dictionary_file | |
| Validate_password_length | 8 |
| Validate_password_mixed_case_count | 1 |
| Validate_password_number_count | 1 |
| Validate_password_policy | MEDIUM |
| Validate_password_special_char_count | 1 |
+--------------------------------------+--------+
6 rows in Set (0.08 sec)

2) Parameter explanation

Validate_password_dictionary_file
The dictionary file path used by the plugin to verify password strength.

Validate_password_length
Password minimum length, parameter defaults to 8, it has the minimum limit, the minimum value is: Validate_password_number_count + Validate_password_special_char_count + (2 * validate_ Password_mixed_case_count)

Validate_password_mixed_case_count
The minimum number of lowercase letters and capitals to include in the password.

Validate_password_number_count
The number of digits that the password must contain at least.

Validate_password_policy
Password strength check level, 0/low, 1/medium, 2/strong. The following values are available:
Policy Tests performed
0 or Low Length
1 or MEDIUM Length; Numeric, lowercase/uppercase, and special characters
2 or strong Length; Numeric, lowercase/uppercase, and special characters; Dictionary file
The default is 1, which is medium, so the password you just started must match the length and must contain numbers, lowercase or uppercase letters, special characters.

Validate_password_special_char_count
The minimum number of special characters the password should contain.

3) modify MySQL parameter configuration

[SQL] View plain copy
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.05 sec)

Mysql>
Mysql>
mysql> set global validate_password_mixed_case_count=0;
Query OK, 0 rows Affected (0.00 sec)

mysql> set global validate_password_number_count=3;
Query OK, 0 rows Affected (0.00 sec)

mysql> set global validate_password_special_char_count=0;
Query OK, 0 rows Affected (0.00 sec)

mysql> set global validate_password_length=3;
Query OK, 0 rows Affected (0.00 sec)

mysql> SHOW VARIABLES like ' validate_password% ';
+--------------------------------------+-------+
| variable_name | Value |
+--------------------------------------+-------+
| Validate_password_dictionary_file | |
| Validate_password_length | 3 |
| Validate_password_mixed_case_count | 0 |
| Validate_password_number_count | 3 |
| Validate_password_policy | Low |
| Validate_password_special_char_count | 0 |
+--------------------------------------+-------+
6 rows in Set (0.00 sec)

4) Modify the simple password:

[SQL] View plain copy
mysql> SET PASSWORD for ' root ' @ ' localhost ' = PASSWORD (' 123 ');
Query OK, 0 rows affected, 1 Warning (0.00 sec)

Installation configuration MySQL

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.