mysql基础1

在centos中默认安装有MariaDB,这个是MySQL的分支更新下yum源
sudo yum update -y
rpm -qa | grep mariadb(系统自带)
卸载
rpm -e –nodeps
安装2个依赖 yum install -y perl net-tools
mysql社区下载
https://dev.mysql.com/downloads/repo/yum/
MySQL Yum存储库
wget https://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
ls
anaconda-ks.cfg mysql-community-release-el7-5.noarch.rpm
rpm mysql table补全
yum -y install mysql-server

systemctl start mysqld
systemctl status mysqld
mysqladmin -u root password ‘445566’
登入mysql -u root -p
本地连接数据库
,远程登入授权
GRANT命令使用说明:

grant all privileges on *.* to username@’localhost’identified by “username” with grant option;

grant命令说明:
all privileges :是表示所有权限,你也可以使用其他权限。

on :用来指定权限针对哪些库和表。

*.* :中前面的*号用来指定数据库名,后面的*号用来指定表名。

to 表示将权限赋予某个用户。
grant all privileges on *.* to ‘root’@’%’ identified by ‘445566’ with grant option;

username@’localhost’ :表示username用户,@后面接限制的主机,可以是IP、IP段、域名以及%,%表示任何地方。

identified by :指定用户的登录密码。

withgrant option :这个选项表示该用户可以将自己拥有的权限授权给别人。
设置防火墙开机自启,如果没有先安装
yum install firewalld
systemctl unmask firewalld
systemctl enable firewalld
systemctl start firewalld

防火墙开启3306端口
firewall-cmd –zone=public –add-port=3306/tcp permanent

netstat -tunlp |grep mysql
tcp6 0 0 :::3306 :::* LISTEN 325822/mysqld
接下来用客户端连接mysql,进行数据增删改查
如果mysql: command not found

echo $PATH

vim /etc/profile

显示/etc/profiexport PATH=/application/mysql/bin:$PATH
le文件的最后一行内容tail -1 /etc/profile
source /etc/profile
mysql -uroot -p(mysql -uroot -p -hlocalhost
show databases;
drop databases
mysql安全配置

设置复杂程度,长度
set global validate_password_policy=
set global validate_password_length=

------本页内容已结束,喜欢请分享------

感谢您的来访,获取更多精彩文章请收藏本站。

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容