Linux->mysql Installation and Commissioning

Source: Internet
Author: User

Environment preparation
    1. Mysql:https://dev.mysql.com/get/downloads/mysql-5.7/mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz
    2. Linux system version: CentOS 7
Installation steps

Https://dev.mysql.com/doc/refman/5.7/en/binary-installation.html

shell> groupadd mysqlshell> useradd -r -g mysql -s /bin/false mysqlshell> cd /usr/localshell> tar zxvf /path/to/mysql-VERSION-OS.tar.gzshell> ln -s full-path-to-mysql-VERSION-OS mysqlshell> cd mysqlshell> mkdir mysql-filesshell> chmod 750 mysql-filesshell> chown -R mysql .shell> chgrp -R mysql .shell> bin/mysql_install_db --user=mysql    # MySQL 5.7.5shell> bin/mysqld --initialize --user=mysql # MySQL 5.7.6 and upshell> bin/mysql_ssl_rsa_setup              # MySQL 5.7.6 and upshell> chown -R root .shell> chown -R mysql data mysql-filesshell> bin/mysqld_safe --user=mysql &# Next command is optionalshell> cp support-files/mysql.server /etc/init.d/mysqldshell> service mysqld start
Test whether the server is installed successfully

To this step service also up. But one problem is that I don't have a password and a user. How can this test server be complete?

To start and change the password by starting Bin/mysql_safe

1. Shut down the MySQL server

[[email protected] init.d]# /etc/rc.d/init.d/mysql stopShutting down MySQL..[ OK ]

2. Start Mysqld_safe Specify--skip-grant-tables

[[email protected] init.d]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

3. Log in to the MySQL server

[[email protected] bin]# ./mysql -u[你的用户名] -p[你的密码]

4. Modify the MySQL root password

shell>use mysql;shell>update user set password=PASSWORD(‘[你的新密码]‘) where user=‘root‘ and host=‘root‘ or host=‘localhost‘;shell>flush privileges;

5. Set MySQL to remote access

shell>user mysql;shell>GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘[你的root密码]‘ WITH GRANT OPTION;shell>flush privileges;

6.mysql database user password has been modified, now re-shut down the MYSQLD server, and then reconnect, the service has officially started, then run a test shell command to see if the server is functioning properly.

-Use Mysqladmin to verify that the server is running.
shell> bin/mysqladmin versionshell> bin/mysqladmin variables

If you cannot connect to the server, specify the-u root option to connect as root. If you have already assigned a password to the root account, you also need to specify-p on the command line and enter the password when prompted. For example:

shell> bin/mysqladmin -u root -p version        Enter password: (enter root password here)

Depending on your platform and MySQL version, the output of the mysqladmin version is slightly different, but should be similar to the following:

shell> bin/mysqladmin version        mysqladmin  Ver 14.12 Distrib 5.7.20, for pc-linux-gnu on i686        ...        Server version          5.7.20        Protocol version        10        Connection              Localhost via UNIX socket        UNIX socket             /var/lib/mysql/mysql.sock        Uptime:                 14 days 5 hours 5 min 21 sec        Threads: 1  Questions: 366  Slow queries: 0        Opens: 0  Flush tables: 1  Open tables: 19        Queries per second avg: 0.000

To see what else you can use mysqladmin, call it using the--HELP option.

Verify shutting down the server

Verify that you can shut down the server (including the-P option if the root account already has a password)

shell> bin/mysqladmin -u root shutdown
Verify re-opening the server

Verify that you can restart the server. Perform this operation by using Mysqld_safe or by calling Mysqld directly. For example:

shell> bin/mysqld_safe --user=mysql &

If the turn-on fails, consult: Reason for failure

To view the existing database

The list of installed databases may vary, but always contain the smallest MySQL and information_schema.

shell> bin/mysqlshow        +--------------------+        |     Databases      |        +--------------------+        | information_schema |        | mysql              |        | performance_schema |        | sys                |        +--------------------+

If you specify a database name, Mysqlshow displays a list of the tables in the database:

shell> bin/mysqlshow mysqldatabase:mysql+---------------------------+| Tables |+---------------------------+| Columns_priv | | db | | Engine_cost | | Event | | Func | | General_log | | gtid_executed | | Help_category | | Help_keyword | | help_relation | | Help_topic | | Innodb_index_stats | | Innodb_table_stats | | Ndb_binlog_index | | Plugin | | Proc | | Procs_priv | | Proxies_priv | | Server_cost | | Servers | | Slave_master_info | | Slave_relay_log_info | | Slave_worker_info | | Slow_log | | Tables_priv | | Time_zone | | Time_zone_leap_second | | Time_zone_name | | time_zone_transition | | Time_zone_transition_type|| User |+---------------------------+
Execute SQL command
shell> bin/mysql -e "SELECT User, Host, plugin FROM mysql.user" mysql+------+-----------+-----------------------+| User | Host      | plugin                |+------+-----------+-----------------------+| root | localhost | mysql_native_password |+------+-----------+-----------------------+

Mysql-mysql command-line tools,

Mysqladmin-Client for managing the MySQL server

Mysqlshow-Displays database, table, and column information.

Linux->mysql Installation and Commissioning

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.