linux mysql操作
如果是云上使用MySQL,首先应该创建用户组,下面操作是针对centos系统的
useradd zyj #创建用户 zyj是我的用户名
passwd zyj #修改密码
下载MySQL包
wget http://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm
安转软件源
将platform-and-version-specific-package-name 替换为你下载的rpm名
sudo rpm -Uvh platform-and-version-specific-package-name.rpm
例如
rpm -Uvh mysql57-community-release-el7-10.noarch.rpm #mysql57-community-release-el7-10.noarch.rpm就是下载的包的名字
安装mysql服务端
yum install -y mysql-community-server
操作:
启动:
service mysql start
停止:
service mysql stop
重启:
service mysql restart
检查mysql 的运行状态:
service mysqld status
修改临时密码
grep 'temporary password' /var/log/mysqld.log
host:后面的就是临时密码
登录
mysql -uroot -p
修改密码
修改密码前做如下操作,否则密码不能设的太简单
mysql> set global validate_password_policy=0;
mysql> set global validate_password_length=1;
修改密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
mysql远程访问
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
flush privileges;
设置MySQL的字符编码,使得MySQL数据能够支持中文编码
show variables like '%char%';
set character_set_server=utf8;