13.1 Settings Change root password 13.2 Connect MySQL 13.3 mysql common command

Source: Internet
Author: User

13.1 Setting Change root password


[Email protected] init.d]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[Email protected] init.d]# path= $PATH:/usr/local/mysql/bin
[Email protected] init.d]# Vim/etc/profile
[Email protected] init.d]# Source/etc/profile
[Email protected] init.d]# Mysql-uroot
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 3
Server version:5.6.35 MySQL Community Server (GPL)
[Email protected] init.d]# mysqladmin-uroot password ' martin.1 '
Warning:using a password on the command line interface can is insecure.
[Email protected] init.d]# Mysql-uroot
ERROR 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:no)
[Email protected] init.d]# mysql-uroot-p
Enter Password:
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 6
Server version:5.6.35 MySQL Community Server (GPL)
To know the root password, change the root password:
[Email protected] init.d]# mysqladmin-uroot-p ' martin.1 ' password ' martin.2 '
Warning:using a password on the command line interface can is insecure.

To change the root password without knowing the root password:
Modify/ETC/MY.CNF First line add skip-grant
Restart MySQL service/etc/init.d/mysqld restart
mysql> use MySQL
Reading table information for completion of table and column names
Can turn off this feature to get a quicker startup with-a
Database changed
Mysql> SELECT * from user where user= ' root ';
mysql> Update user Set Password=password (' Martinlinux ') where user= ' root ';
Query OK, 4 rows Affected (0.02 sec)
Rows Matched:4 Changed:4 warnings:0

13.2 Connecting MySQL


[Email protected] ~]# mysql-uroot-p ' martinlinux '-h127.0.0.1-p3306
Warning:using a password on the command line interface can is insecure.
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 7
Server version:5.6.35 MySQL Community Server (GPL)
[Email protected] ~]# mysql-uroot-p ' martinlinux '-s/tmp/mysql.sock
Warning:using a password on the command line interface can is insecure.
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 8
[Email protected] ~]# mysql-uroot-p ' martinlinux '-e "show Databases"
Warning:using a password on the command line interface can is insecure.
+--------------------+
| Database |
+--------------------+
| Information_schema |
| MySQL |
| Performance_schema |
| Test |
+--------------------+

13.3 MySQL Common commands

Creating the library create database db1;
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| db1 |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in Set (0.01 sec)
To create table use DB1; creation table T1 ( ID int (4), name Char (40));
mysql> Show create TABLE t1\g;
1. Row
table:t1
Create table:create Table T1 (
ID int (4) DEFAULT NULL,
name char (max) default NULL
) engine=innodb default Charset=utf8
1 row in Set (0.01 sec)

View current database version select version ();
Mysql> select version ();
+-----------+
| Version () |
+-----------+
| 5.6.35 |
+-----------+
1 row in Set (0.00 sec)

View database status Show status;

Mysql> Show status;
+-----------------------------------------------+-------------+
| variable_name | Value |
+-----------------------------------------------+-------------+
| aborted_clients | 0 |
| aborted_connects | 4 |
| Binlog_cache_disk_use | 0 |
| Binlog_cache_use | 0 |
| Binlog_stmt_cache_disk_use | 0 |
| Binlog_stmt_cache_use | 0 |
| bytes_received | 1634 |
| bytes_sent | 69469 |

View each parameter show variables; Show variables like ' max_connect% ';
Mysql> Show variables like ' max_connect% ';
+--------------------+-------+
| variable_name | Value |
+--------------------+-------+
| max_connect_errors | 100 |
| max_connections | 151 |
+--------------------+-------+
2 rows in Set (0.00 sec)

Modify parameter set global max_connect_errors=1000;
mysql> Set Global max_connect_errors = 1000;
Query OK, 0 rows affected (0.01 sec)

View queue show Processlist; Show full processlist;
Mysql> show Processlist;
+----+------+-----------+------+---------+------+-------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------+------+---------+------+-------+------------------+
| 10 | Root | localhost | DB1 | Query | 0 | init | Show Processlist |
+----+------+-----------+------+---------+------+-------+------------------+
1 row in Set (0.01 sec)

Mysql> Show full processlist;
+----+------+-----------+------+---------+------+-------+-----------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------+------+---------+------+-------+-----------------------+
| 10 | Root | localhost | DB1 | Query | 0 | init | Show Full Processlist |
+----+------+-----------+------+---------+------+-------+-----------------------+
1 row in Set (0.00 sec)

13.1 Settings Change root password 13.2 Connect MySQL 13.3 mysql common command

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.