Learning Mysql

1. CentOS安装mysql8

获取并安装源:

wget http://dev.mysql.com/get/mysql80-community-release-el7-2.noarch.rpm
yum -y install mysql80-community-release-el7-2.noarch.rpm

安装组件:

yum -y install mysql mysql-community-server mysql-community-client mysql-community-devel mysql-community-libs mysql-community-libs-compat

启动服务:

systemctl start mysqld.service

systemctl enable mysqld

systemctl daemon-reload

修改root密码,新建用户并允许远程访问:

grep "password" /var/log/mysqld.log

mysql -u root -p

ALTER USER 'root'@'localhost' IDENTIFIED BY '******';

CREATE USER 'clear'@'%' IDENTIFIED BY '*******';

GRANT ALL PRIVILEGES on *.* to 'clear'@'%';

ALTER user 'clear'@'%' IDENTIFIED WITH mysql_native_password BY '*******';

flush privileges;

 

2. 统计一个数据库中每张表的行数

use information_schema;
select table_name,table_rows from tables where TABLE_SCHEMA = '数据库名' order by table_rows desc;

 

你可能感兴趣的:(Mysql)