时间:2021-07-01 10:21:17 帮助过:89人阅读
用root权限打开命令行界面,执行以下yum指令:
yum安装MySQL
yum install mysql mysql-server mysql-devel -y
|
在最终提示Complete!表示安装成功。
安装完毕后,查看是否生成了mysqld服务——即MySQL的服务端。如果不是自动启动的话,可以设定为自动启动:
启动服务端
[root@localhost ~] # chkconfig --list|grep mysql
mysqld 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@localhost ~] # chkconfig mysqld on
[root@localhost ~] # chkconfig --list|grep mysql
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
|
也可以直接用service指令启动服务。
通过yum安装MySQL后,默认目录为“/var/lib/mysql”,进入目录:
MySQL目录
[root@localhost mysql] # pwd
/var/lib/mysql
[root@localhost mysql] # ll
total 20488
-rw-rw---- 1 mysql mysql 10485760 Jul 13 06:21 ibdata1
-rw-rw---- 1 mysql mysql 5242880 Jul 13 06:21 ib_logfile0
-rw-rw---- 1 mysql mysql 5242880 Jul 13 06:21 ib_logfile1
drwx------ 2 mysql mysql 4096 Jul 13 06:21 mysql
srwxrwxrwx 1 mysql mysql 0 Jul 13 06:21 mysql.sock
drwx------ 2 mysql mysql 4096 Jul 13 06:21 test
|
发现有两个库,都是mysql默认自带的。
[root@localhost mysql] # netstat -nultp|grep mysql
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 15086 /mysqld
|
MySQL默认占用3306端口
直接执行,yum安装的mysql,本地root密码默认为空。
连接MySQL
[root@localhost mysql] # mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.71 Source distribution
Copyright (c) 2000, 2013, Oracle and /or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and /or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
mysql>
|
设置新密码并授予权限,刷新权限使之生效:(例密码设置为“123456”)
设置权限
mysql> grant all on *.* to root@ ‘%‘ identified by ‘123456‘ ;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit ;
Bye
|
MySQL数据库安装与启动(Linux)
标签:name acl listen iat title rpo host evel chkconfig