zoukankan      html  css  js  c++  java
  • 源码编译安装mysql

    环境说明:此次安装是在RedHead Enterprise Linux 6.5操作系统上

    准备mysql-5.5.32.tar.gz  mysql-5.6.26.tar.gz及mysql-5.7.2-m12.tar.gz软件包

    使用YUM解决依赖

    [root@sishen ~]# yum install -y cmake ncurses-devel

    添加mysql用户

    [root@sishen ~]# useradd -u 8001 -s /sbin/nologin  mysql

    解压并查看

    [root@sishen ~]# tar -xf /mysql/mysql-5.5.32.tar.gz -C /usr/local/mysql/
    [root@sishen ~]# cd !$
    cd /usr/local/mysql/

    [root@sishen mysql]# ll
    total 8
    drwxr-xr-x  2 root  root  4096 Oct 12 10:46 data
    drwxr-xr-x 32 mysql mysql 4096 Oct 12 10:34 mysql-5.5.32

    [root@sishen mysql]# cd mysql-5.5.32/
    [root@sishen mysql-5.5.32]# ls
    BUILD            COPYING             libmysqld    regex          tests
    BUILD-CMAKE      dbug                libservices  scripts        unittest
    client           Docs                man          sql            VERSION
    cmake            extra               mysql-test   sql-bench      vio
    CMakeLists.txt   include             mysys        sql-common     win
    cmd-line-utils   INSTALL-SOURCE      packaging    storage        zlib
    config.h.cmake   INSTALL-WIN-SOURCE  plugin       strings
    configure.cmake  libmysql            README       support-files

    编译安装

    [root@sishen mysql-5.5.32]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_USER=mysql

    参数说明:

    -DCMAKE_INSTALL_PREFIX                       //数据库安装目录

    -DMYSQL_UNIX_ADDR sock                      // 文件路径

    -DDEFAULT_CHARSET                                  //默认字符集

    -DDEFAULT_COLLATION                              //默认字符校对

    -DWITH_EXTRA_CHARSETS                         //扩展字符支持 默认all

    -DWITH_storage_STORAGE_ENGINE      // 存储引擎的支持,默认支持MyISAM,MERGE,MEMORY,CVS存储引擎

    -DENABLED_LOCAL_INFILE=1                   //启用加载本地数据

    -DMYSQL_DATADIR                                     //数据存放目录

    -DMYSQL_USER mysql                                //运行用户

    [root@sishen mysql-5.5.32]# echo $?
    0
    [root@sishen mysql-5.5.32]# make -j 4

    [root@sishen mysql-5.5.32]# echo $?
    0

    给mysql用户授权

    [root@sishen mysql-5.5.32]# chown -R mysql:mysql /usr/local/mysql/
    [root@sishen mysql-5.5.32]# chmod 1777 /tmp/

    创建配置文件

    [root@sishen mysql-5.5.32]# cp support-files/my-large.cnf /etc/my.cnf
    cp: overwrite `/etc/my.cnf'? y

    设置环境变量

    [root@sishen mysql-5.5.32]# echo 'export PATH=/usr/local/mysql/bin:/usr/local/mysql/scripts:$PATH'>> /etc/profile

    [root@sishen mysql-5.5.32]# tail -n -1 /etc/profile
    export PATH=/usr/local/mysql/bin:$PATH

    [root@sishen mysql-5.5.32]# source /etc/profile

    创建服务启动脚本,添加开机启动
    [root@sishen mysql-5.5.32]# cp support-files/mysql.server /etc/init.d/mysqld
    [root@sishen mysql-5.5.32]# chmod +x /etc/init.d/mysqld

                basedir=/usr/local/mysql
                datadir=/usr/local/mysql/data

    [root@sishen mysql]# chkconfig mysqld on

    初始化数据库

    [root@sishen mysql]# mysql_install_db --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --user=mysql
    WARNING: The host 'sishen.163' could not be looked up with resolveip.
    This probably means that your libc libraries are not 100 % compatible
    with this binary MySQL version. The MySQL daemon, mysqld, should work
    normally with the exception that host name resolving will not work.
    This means that you should use IP addresses instead of hostnames
    when specifying MySQL privileges !
    Installing MySQL system tables...            //看到这两个OK就说明初始化数据库成功
    OK
    Filling help tables...
    OK

    …….

    开启mysqld服务

    [root@sishen mysql]# service mysqld start
    Starting MySQL...                                          [  OK  ]

    安全初始化

    [root@sishen mysql]# mysql_secure_installation


    NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
          SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!


    In order to log into MySQL to secure it, we'll need the current
    password for the root user.  If you've just installed MySQL, and
    you haven't set the root password yet, the password will be blank,
    so you should just press enter here.

    Enter current password for root (enter for none):                                    //这里直接回车即可
    OK, successfully used password, moving on...

    Setting the root password ensures that nobody can log into the MySQL
    root user without the proper authorisation.

    Set root password? [Y/n] y
    New password:
    Re-enter new password:
    Password updated successfully!
    Reloading privilege tables..
    ... Success!


    By default, a MySQL installation has an anonymous user, allowing anyone
    to log into MySQL without having to have a user account created for
    them.  This is intended only for testing, and to make the installation
    go a bit smoother.  You should remove them before moving into a
    production environment.

    Remove anonymous users? [Y/n] y
    ... Success!

    Normally, root should only be allowed to connect from 'localhost'.  This
    ensures that someone cannot guess at the root password from the network.

    Disallow root login remotely? [Y/n] y
    ... Success!

    By default, MySQL comes with a database named 'test' that anyone can
    access.  This is also intended only for testing, and should be removed
    before moving into a production environment.

    Remove test database and access to it? [Y/n] y
    - Dropping test database...
    ... Success!
    - Removing privileges on test database...
    ... Success!

    Reloading the privilege tables will ensure that all changes made so far
    will take effect immediately.

    Reload privilege tables now? [Y/n] y
    ... Success!

    Cleaning up...

    All done!  If you've completed all of the above steps, your MySQL
    installation should now be secure.

    Thanks for using MySQL!

    登录测试mysql

    [root@sishen mysql]# mysql -uroot -p123456
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 9
    Server version: 5.5.32-log Source distribution

    mysql> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    +--------------------+
    3 rows in set (0.00 sec)

    至此mysql-5.5.32安装完成

    mysql-5.6.26的安装类似,下面简单列举出来安装步骤

    [root@sishen mysql]# mkdir /usr/local/mysql-5.6

    [root@sishen mysql-5.6]# tar -xf /mysql/mysql-5.6.26.tar.gz -C /usr/local/mysql-5.6/

    [root@sishen mysql-5.6]# chown -R mysql:mysql /usr/local/mysql-5.6/

    [root@sishen mysql-5.6.26]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.6 -DMYSQL_UNIX_ADDR=/tmp/mysql-5.6.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/usr/local/mysql-5.6/data -DMYSQL_USER=mysql

    [root@sishen mysql-5.6.26]# echo $?
    0

    [root@sishen mysql-5.6.26]# make -j 4

    [root@sishen mysql-5.6.26]# echo $?
    0

    [root@sishen mysql-5.6.26]# make install

    [root@sishen mysql-5.6.26]# echo $?
    0

    [root@sishen ~]# cp support-files/my-default.cnf /etc/my5.6.cnf

    [root@sishen ~]# cp support-files/mysql.server /etc/init.d/mysql5.6

    [root@sishen ~]# vim /etc/init.d/mysql5.6

    basedir=/usr/local/mysql-5.6
    datadir=/usr/local/mysql-5.6/data

    [root@sishen ~]# chkconfig mysql5.6 on
    [root@sishen ~]# echo 'export PATH=/usr/local/mysql-5.6/scripts:$PATH' >> /etc/profile
    [root@sishen ~]# source !$
    source /etc/profile

    [root@sishen ~]# echo 'export PATH=/usr/local/mysql-5.6/bin:$PATH'>> /etc/profile
    [root@sishen ~]# source !$
    source /etc/profile

    初始化数据库

    [root@sishen ~]# mysql_install_db --defaults-file=/etc/my5.6.cnf --basedir=/usr/local/mysql-5.6/ --datadir=/usr/local/mysql-5.6/data/ --user=mysql

    WARNING: The host 'sishen.163' could not be looked up with /usr/local/mysql-5.6//bin/resolveip.
    This probably means that your libc libraries are not 100 % compatible
    with this binary MySQL version. The MySQL daemon, mysqld, should work
    normally with the exception that host name resolving will not work.
    This means that you should use IP addresses instead of hostnames
    when specifying MySQL privileges !

    Installing MySQL system tables...2016-10-12 12:17:11 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
    2016-10-12 12:17:11 0 [Note] /usr/local/mysql-5.6//bin/mysqld (mysqld 5.6.26) starting as process 18221 ...
    2016-10-12 12:17:11 18221 [Note] InnoDB: Using atomics to ref count buffer pool pages
    2016-10-12 12:17:11 18221 [Note] InnoDB: The InnoDB memory heap is disabled
    2016-10-12 12:17:11 18221 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
    2016-10-12 12:17:11 18221 [Note] InnoDB: Memory barrier is not used
    2016-10-12 12:17:11 18221 [Note] InnoDB: Compressed tables use zlib 1.2.3
    2016-10-12 12:17:11 18221 [Note] InnoDB: Using CPU crc32 instructions
    2016-10-12 12:17:11 18221 [Note] InnoDB: Initializing buffer pool, size = 128.0M
    2016-10-12 12:17:11 18221 [Note] InnoDB: Completed initialization of buffer pool
    2016-10-12 12:17:11 18221 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
    2016-10-12 12:17:11 18221 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
    2016-10-12 12:17:11 18221 [Note] InnoDB: Database physically writes the file full: wait...
    2016-10-12 12:17:11 18221 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
    2016-10-12 12:17:12 18221 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
    2016-10-12 12:17:13 18221 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
    2016-10-12 12:17:13 18221 [Warning] InnoDB: New log files created, LSN=45781
    2016-10-12 12:17:13 18221 [Note] InnoDB: Doublewrite buffer not found: creating new
    2016-10-12 12:17:13 18221 [Note] InnoDB: Doublewrite buffer created
    2016-10-12 12:17:13 18221 [Note] InnoDB: 128 rollback segment(s) are active.
    2016-10-12 12:17:13 18221 [Warning] InnoDB: Creating foreign key constraint system tables.
    2016-10-12 12:17:14 18221 [Note] InnoDB: Foreign key constraint system tables created
    2016-10-12 12:17:14 18221 [Note] InnoDB: Creating tablespace and datafile system tables.
    2016-10-12 12:17:14 18221 [Note] InnoDB: Tablespace and datafile system tables created.
    2016-10-12 12:17:14 18221 [Note] InnoDB: Waiting for purge to start
    2016-10-12 12:17:14 18221 [Note] InnoDB: 5.6.26 started; log sequence number 0
    2016-10-12 12:17:14 18221 [Note] Binlog end
    2016-10-12 12:17:14 18221 [Note] InnoDB: FTS optimize thread exiting.
    2016-10-12 12:17:14 18221 [Note] InnoDB: Starting shutdown...
    2016-10-12 12:17:15 18221 [Note] InnoDB: Shutdown completed; log sequence number 1625977
    OK

    Filling help tables...2016-10-12 12:17:15 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
    2016-10-12 12:17:15 0 [Note] /usr/local/mysql-5.6//bin/mysqld (mysqld 5.6.26) starting as process 18243 ...
    2016-10-12 12:17:15 18243 [Note] InnoDB: Using atomics to ref count buffer pool pages
    2016-10-12 12:17:15 18243 [Note] InnoDB: The InnoDB memory heap is disabled
    2016-10-12 12:17:15 18243 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
    2016-10-12 12:17:15 18243 [Note] InnoDB: Memory barrier is not used
    2016-10-12 12:17:15 18243 [Note] InnoDB: Compressed tables use zlib 1.2.3
    2016-10-12 12:17:15 18243 [Note] InnoDB: Using CPU crc32 instructions
    2016-10-12 12:17:15 18243 [Note] InnoDB: Initializing buffer pool, size = 128.0M
    2016-10-12 12:17:15 18243 [Note] InnoDB: Completed initialization of buffer pool
    2016-10-12 12:17:15 18243 [Note] InnoDB: Highest supported file format is Barracuda.
    2016-10-12 12:17:15 18243 [Note] InnoDB: 128 rollback segment(s) are active.
    2016-10-12 12:17:15 18243 [Note] InnoDB: Waiting for purge to start
    2016-10-12 12:17:15 18243 [Note] InnoDB: 5.6.26 started; log sequence number 1625977
    2016-10-12 12:17:15 18243 [Note] Binlog end
    2016-10-12 12:17:15 18243 [Note] InnoDB: FTS optimize thread exiting.
    2016-10-12 12:17:15 18243 [Note] InnoDB: Starting shutdown...
    2016-10-12 12:17:17 18243 [Note] InnoDB: Shutdown completed; log sequence number 1625987
    OK

    To start mysqld at boot time you have to copy
    support-files/mysql.server to the right place for your system

    PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !        //mysql5.6与mysql5.5在这一步会有所区别
    To do so, start the server, then issue the following commands:

      /usr/local/mysql-5.6//bin/mysqladmin -u root password 'new-password'
      /usr/local/mysql-5.6//bin/mysqladmin -u root -h sishen.163 password 'new-password'

    Alternatively you can run:

      /usr/local/mysql-5.6//bin/mysql_secure_installation

    which will also give you the option of removing the test
    databases and anonymous user created by default.  This is
    strongly recommended for production servers.

    See the manual for more instructions.

    You can start the MySQL daemon with:

      cd . ; /usr/local/mysql-5.6//bin/mysqld_safe &

    You can test the MySQL daemon with mysql-test-run.pl

      cd mysql-test ; perl mysql-test-run.pl

    Please report any problems at http://bugs.mysql.com/

    The latest information about MySQL is available on the web at

      http://www.mysql.com

    Support MySQL by buying support/licenses at http://shop.mysql.com

    New default config file was created as /usr/local/mysql-5.6//my.cnf and
    will be used by default by the server when you start it.
    You may edit this file to change server settings

    WARNING: Default config file /etc/my.cnf exists on the system
    This file will be read by default by the MySQL server
    If you do not want to use this, either remove it, or use the
    --defaults-file argument to mysqld_safe when starting the server

    [root@sishen ~]# mysql_secure_installation

    NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
          SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!


    In order to log into MySQL to secure it, we'll need the current
    password for the root user.  If you've just installed MySQL, and
    you haven't set the root password yet, the password will be blank,
    so you should just press enter here.

    Enter current password for root (enter for none):
    OK, successfully used password, moving on...

    Setting the root password ensures that nobody can log into the MySQL
    root user without the proper authorisation.

    Set root password? [Y/n] y

    New password:
    Re-enter new password:
    Password updated successfully!
    Reloading privilege tables..
    ... Success!


    By default, a MySQL installation has an anonymous user, allowing anyone
    to log into MySQL without having to have a user account created for
    them.  This is intended only for testing, and to make the installation
    go a bit smoother.  You should remove them before moving into a
    production environment.

    Remove anonymous users? [Y/n] y
    ... Success!

    Normally, root should only be allowed to connect from 'localhost'.  This
    ensures that someone cannot guess at the root password from the network.

    Disallow root login remotely? [Y/n] y
    ... Success!

    By default, MySQL comes with a database named 'test' that anyone can
    access.  This is also intended only for testing, and should be removed
    before moving into a production environment.

    Remove test database and access to it? [Y/n] y
    - Dropping test database...
    ... Success!
    - Removing privileges on test database...
    ... Success!

    Reloading the privilege tables will ensure that all changes made so far
    will take effect immediately.

    Reload privilege tables now? [Y/n] y
    ... Success!

    Cleaning up...

    All done!  If you've completed all of the above steps, your MySQL
    installation should now be secure.

    Thanks for using MySQL!

    [root@sishen ~]# mysql -u root -p123456
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 10
    Server version: 5.6.26-log Source distribution

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

    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.

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

    mysql> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    +--------------------+
    3 rows in set (0.00 sec)

    至此安装完成

    mysql-5.7安装

    [root@sishen mysql-5.7.2-m12]# mkdir -p /usr/local/mysql-5.7/data

    [root@sishen mysql-5.7.2-m12]# tar -xf /mysql/mysql-5.7.2-m12.tar.gz -C /usr/local/mysql-5.7/

    [root@sishen mysql-5.7.2-m12]# pwd
    /usr/local/mysql-5.7/mysql-5.7.2-m12

    [root@sishen mysql-5.7.2-m12]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.7 -DMYSQL_UNIX_ADDR=/tmp/mysql5.7.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/usr/local/mysql-5.7/data -DMYSQL_USER=mysql

    [root@sishen mysql-5.7.2-m12]# echo $?
    0

    [root@sishen mysql-5.7.2-m12]# make -j 4

    [root@sishen mysql-5.7.2-m12]# echo $?
    0

    [root@sishen mysql-5.7.2-m12]# make install

    [root@sishen mysql-5.7]# ls
    bin      docs            lib              mysql-test  share
    COPYING  include         man              README      sql-bench
    data     INSTALL-BINARY  mysql-5.7.2-m12  scripts     support-files

    [root@sishen mysql-5.7]# echo 'export PATH=/usr/local/mysql-5.7/bin:$PATH'>> /etc/profile
    [root@sishen mysql-5.7]# echo 'export PATH=/usr/local/mysql-5.7/mysql-5.7.2-m12/scripts:$PATH'>> /etc/profile
    [root@sishen mysql-5.7]# source !$
    source /etc/profile

    [root@sishen mysql-5.7]# cd mysql-5.7.2-m12/
    [root@sishen mysql-5.7.2-m12]# cp support-files/mysql.server /etc/init.d/mysql5.7

    [root@sishen mysql-5.7.2-m12]# chmod +x /etc/init.d/mysql5.7
    [root@sishen mysql-5.7.2-m12]# vim /etc/init.d/mysql5.7

    basedir=/usr/local/mysql-5.7/
    datadir=/usr/local/mysql-5.7/data

    [root@sishen mysql-5.7.2-m12]# cp support-files/my-default.cnf /etc/my5.7.cnf

    [root@sishen ~]# chown -R mysql:mysql /usr/local/mysql-5.7/
    [root@sishen ~]# mysql_install_db --defaults-file=/etc/my5.7.cnf --basedir=/usr/local/mysql-5.7/ --datadir=/usr/local/mysql-5.7/data/ --user=mysql

    WARNING: The host 'sishen.163' could not be looked up with /usr/local/mysql-5.7//bin/resolveip.
    This probably means that your libc libraries are not 100 % compatible
    with this binary MySQL version. The MySQL daemon, mysqld, should work
    normally with the exception that host name resolving will not work.
    This means that you should use IP addresses instead of hostnames
    when specifying MySQL privileges !

    Installing MySQL system tables...2016-10-12T05:20:24.703100Z 0 [Warning] The syntax '--log_warnings/-W' is deprecated and will be removed in a future release. Please use '--log_error_verbosity' instead.
    OK

    Filling help tables...2016-10-12T05:20:29.505388Z 0 [Warning] The syntax '--log_warnings/-W' is deprecated and will be removed in a future release. Please use '--log_error_verbosity' instead.
    OK

    To start mysqld at boot time you have to copy
    support-files/mysql.server to the right place for your system

    PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
    To do so, start the server, then issue the following commands:

      /usr/local/mysql-5.7//bin/mysqladmin -u root password 'new-password'
      /usr/local/mysql-5.7//bin/mysqladmin -u root -h sishen.163 password 'new-password'

    Alternatively you can run:

      /usr/local/mysql-5.7//bin/mysql_secure_installation

    which will also give you the option of removing the test
    databases and anonymous user created by default.  This is
    strongly recommended for production servers.

    See the manual for more instructions.

    You can start the MySQL daemon with:

      cd . ; /usr/local/mysql-5.7//bin/mysqld_safe &

    You can test the MySQL daemon with mysql-test-run.pl

      cd mysql-test ; perl mysql-test-run.pl

    Please report any problems at http://bugs.mysql.com/

    The latest information about MySQL is available on the web at

      http://www.mysql.com

    Support MySQL by buying support/licenses at http://shop.mysql.com

    New default config file was created as /usr/local/mysql-5.7//my.cnf and       
    will be used by default by the server when you start it.
    You may edit this file to change server settings

    WARNING: Default config file /etc/my.cnf exists on the system
    This file will be read by default by the MySQL server
    If you do not want to use this, either remove it, or use the
    --defaults-file argument to mysqld_safe when starting the server

    [root@xuegod63 mysql]# ./bin/mysql_secure_installation

    NOTE: RUNNING ALL THE STEPS FOLLOWING THIS IS RECOMMENDED
    FOR ALL MySQL SERVERS IN PRODUCTION USE!  PLEASE READ EACH
    STEP CAREFULLY!


    In order to log into MySQL to secure it, we'll need the
    current password for the root user. If you've just installed
    MySQL, and you haven't set the root password yet, the
    password will be blank, so you should just press enter here.

    Enter password:


    OK, successfully used password, moving on...

    VALIDATE PASSWORD PLUGIN can be used to test passwords
    and improve security. It checks the strength of password
    and allows the users to set only those passwords which are
    secure enough. Would you like to setup VALIDATE PASSWORD plugin?

    Press y|Y for Yes, any other key for No: y


    There are three levels of password validation policy.

    Please enter 0 for LOW, 1 for MEDIUM and 2 for STRONG: o

    Invalid option provided.


    There are three levels of password validation policy.

    Please enter 0 for LOW, 1 for MEDIUM and 2 for STRONG: 0


    Setting the root password ensures that nobody can log into
    the MySQL root user without the proper authorisation.
    Please set the root password here.

    New password:

    Re-enter new password:

    Strength of the password: 25

    Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
    ... Failed! Error: Your password does not satisfy the current policy requirements

    New password:                          //密码要包含大小写字母和数字且长度至少6位,否则通过不了

    Re-enter new password:

    Strength of the password: 50

    Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
    By default, a MySQL installation has an anonymous user,
    allowing anyone to log into MySQL without having to have
    a user account created for them. This is intended only for
    testing, and to make the installation go a bit smoother.
    You should remove them before moving into a production
    environment.

    Remove anonymous users? (Press y|Y for Yes, any other key for No) : y


    Success.. Moving on..

    Normally, root should only be allowed to connect from
    'localhost'. This ensures that someone cannot guess at
    the root password from the network.

    Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
    Done.. Moving on..

    By default, MySQL comes with a database named 'test' that
    anyone can access. This is also intended only for testing,
    and should be removed before moving into a production
    environment.


    Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
    - Dropping test database...
    ... Success!
    - Removing privileges on test database...
    ... Success!
    Reloading the privilege tables will ensure that all changes
    made so far will take effect immediately.

    Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
    ... Success!
    All done! If you've completed all of the above steps, your
    MySQL installation should now be secure.

    遇到的问题

    [root@sishen ~]# service mysqld restart
    Shutting down MySQL..                                      [  OK  ]
    Starting MySQL.                                            [  OK  ]
    [root@sishen ~]# mysql -uroot -pSishen123456
    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

    解决办法

    [root@sishen ~]# vim /etc/my.cnf

    basedir = /usr/local/mysql
    datadir = /usr/local/mysql/data
    port = 3306
    socket = /var/lib/mysql/mysql.sock

    [root@sishen ~]# service mysqld restart
    Shutting down MySQL..                                      [  OK  ]
    Starting MySQL.                                            [  OK

    [root@sishen ~]# mysql -uroot -pSishen123456
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 1
    Server version: 5.7.2-m12 Source distribution

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

    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.

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

    mysql> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    +--------------------+
    3 rows in set (0.01 sec)

    mysql> exit

    Bye

    记录学习过程中的点滴!积聚经验~~

  • 相关阅读:
    华为手机打不出logcat信息的解决办法
    android经典框架整理和学习
    电脑开机后的用户名跟密码全忘了,怎么办?
    分区修复软件使用简介
    Hardware Acceleration
    Ubuntu常用命令总结
    ubuntu 安装JDK方法
    Invalid layout of java.lang.String at value
    C# DateTime formate
    js获取url中的参数
  • 原文地址:https://www.cnblogs.com/zd520pyx1314/p/5953568.html
Copyright © 2011-2022 走看看