1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
| [iyunv@mysql ~]# yum -y install mysql mysql-server mysql-devel
Loaded plugins: fastestmirror, security
base | 3.7 kB 00:00
base/primary_db | 4.6 MB 00:30
extras | 3.4 kB 00:00
extras/primary_db | 37 kB 00:00
updates | 3.4 kB 00:00
updates/primary_db | 5.2 MB 00:43
...略
[iyunv@mysql ~]# chkconfig mysqld on
#开机启动
[iyunv@mysql ~]# chkconfig --list | grep mysqld
#查询是否开机启动
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[iyunv@mysql ~]# service mysqld start
#启动服务
Starting mysqld: [ OK ]
[iyunv@mysql ~]# mysql
#进入mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.73 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> CREATE DATABASE wordpress;
#创建一个名称为wordpress的数据库
Query OK, 1 row affected (0.00 sec)
mysql> select user,host,password from mysql.user;
#查询用户等信息
+------+-----------+----------+
| user | host | password |
+------+-----------+----------+
| root | localhost | |
| root | mysql | |
| root | 127.0.0.1 | |
| | localhost | |
| | mysql | |
+------+-----------+----------+
5 rows in set (0.00 sec)
mysql> set password for root@localhost=password('root');
#查询用户的密码,都为空,用上面的命令设置root的密码为root
Query OK, 0 rows affected (0.00 sec)
mysql> select user,host,password from mysql.user;
#再次查询发现password下面已有密码信息
+------+-----------+-------------------------------------------+
| user | host | password |
+------+-----------+-------------------------------------------+
| root | localhost | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| root | mysql | |
| root | 127.0.0.1 | |
| | localhost | |
| | mysql | |
+------+-----------+-------------------------------------------+
5 rows in set (0.00 sec)
mysql> exit
Bye
[iyunv@mysql ~]#
[iyunv@mysql ~]# mysql -u root -p
#用新密码登录
Enter password:
#填写密码
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.1.73 Source distribution
...略
mysql> exit
[iyunv@mysql ~]#
[iyunv@mysql ~]# cat /etc/my.cnf
#/etc/my.cnf是mysql的主配置文件
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[iyunv@mysql ~]#
[iyunv@mysql ~]# ls -l /var/lib/mysql/
#mysql数据库的数据库文件存放位置
total 20492
-rw-rw----. 1 mysql mysql 10485760 May 16 22:30 ibdata1
-rw-rw----. 1 mysql mysql 5242880 May 16 22:30 ib_logfile0
-rw-rw----. 1 mysql mysql 5242880 May 16 22:30 ib_logfile1
drwx------. 2 mysql mysql 4096 May 16 22:30 mysql
srwxrwxrwx. 1 mysql mysql 0 May 16 22:30 mysql.sock
drwx------. 2 mysql mysql 4096 May 16 22:30 test
drwx------. 2 mysql mysql 4096 May 16 22:33 wordpress
[iyunv@mysql ~]#
[iyunv@mysql ~]# ls /var/log/
#日志文件存放位置
anaconda.ifcfg.log anaconda.yum.log dmesg mysqld.log tallylog
anaconda.log audit dmesg.old ntpstats wtmp
anaconda.program.log boot.log dracut.log prelink yum.log
anaconda.storage.log btmp lastlog sa
anaconda.syslog ConsoleKit maillog secure
anaconda.xlog cron messages spooler
[iyunv@mysql ~]#
[iyunv@mysql ~]# netstat -lntup|grep 3306
#查看mysql端口侦听状态
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2053/mysqld
[iyunv@mysql ~]#
|