当前位置: 移动技术网 > IT编程>数据库>Mysql > Linux下安装mysql

Linux下安装mysql

2018年09月09日  | 移动技术网IT编程  | 我要评论

第1步、yum安装mysql

yum -y install mysql-server

第2步、设置开机启动

chkconfig mysqld on

第3步、启动MySql服务

service mysqld start

第4步、设置MySql的root用户密码

[root@stonex ~]#  mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
...... 省略了一些行
mysql> select user,host,password from mysql.user;
查询用户的密码,都为空,用下面的命令设置root的密码为root
mysql> set password for root@localhost=password('root');
mysql> exit

第5步、用新密码登录

mysql -u root -p

第6步、开发远程登录权限

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
FLUSH PRIVILEGES;

第7步、将mysql端口对外开放

切换目录到/etc/sysconfig,编辑iptables,将-A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT拷贝到里面去。

第8步、重启防火墙

service iptables restart

第9步、开启root权限

进入mysql:mysql -u root -p

赋予权限:grant all privileges on *.* to 'root'@'% 'identified by 'root' with grant option;

刷新权限列表:flush privileges;

重启mysql:service mysql restart

Mysql基本命令

 

show databases; //查看系统已存在的数据库
use databasesname;   //选择需要使用的数据库
drop database databasename; //删除选定的数据库
exit    //退出数据库的连接
create database test01;    //建立名为test的数据库
show tables;        // 列出当前数据库下的表
其他基本的增删改查使用标准SQL即可

本文地址:https://blog.csdn.net/liangyongyx/article/details/107143195

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网