首页 > 系统 > CentOS > 正文

分享Centos6.5 mysql折腾记

2020-10-28 18:47:44
字体:
来源:转载
供稿:网友

1、yum安装mysql

[root@localhost ~]# yum -y install mysql-server

安装结果

Installed: mysql-server.x86_64 0:5.1.73-7.el6                        Dependency Installed: mysql.x86_64 0:5.1.73-7.el6         perl-DBD-MySQL.x86_64 0:4.013-3.el6        Complete!

2、设置开机启动

[root@localhost ~]# chkconfig mysqld on

3、MySQL服务

3.1、MySQL服务开启

[root@localhost ~]# service mysqld start

3.2、MySQL服务关闭

[root@localhost ~]# service mysqld stop

3.1、MySQL服务重启

[root@localhost ~]# service mysqld restart

4、MySQL密码

4.1、设置密码

[root@stonex ~]# mysql -u rootmysql> set password for root@localhost=password('root');mysql> exit

4.2、密码忘记

4.2.1、修改/etc/my.cnf

[mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sockuser=mysql#最重要的下面这一行代码skip-grant-tables# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0[mysqld_safe]log-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pid

4.2.2、重启MySql

[root@localhost ~]# service mysqld restart

4.2.3、修改密码

 [root@localhost ~]# mysql -u root mysql> use mysql; mysql> set password for root@localhost=password('root'); mysql> flush privileges; mysql> exit; [root@localhost ~]# service mysqld restart

4.2.4、修改/etc/my.cnf

[mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sockuser=mysql# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0[mysqld_safe]log-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pid

4.3、MySQL登陆

[root@localhost ~]# mysql -u root -p

4.4、MySQL常用命令

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

4.5、MySQL开放远程登陆权限

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

以上是小编给大家分享的Centos6.5 mysql折腾记,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对武林网网站的支持!

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表