九周第四次课
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了九周第四次课相关的知识,希望对你有一定的参考价值。
11.1 LAMP架构介绍
Linux + Apache(httpd)+ mysql + php mark
PHP网站(Google、淘宝、百度、51cto博客、猿课论坛)
三个角色可以在一台机器、也可以分开(httpd和PHP要在一起)
LAMP架构介绍
httpd 、 PHP 、MySQL 三者如何工作
Apache(httpd)和 PHP是一个整体 (PHP是以一个模块的形式和Apache结合在一起)
但是Apache不能直接和MySQL 相互打交道,等通过PHP 模块,去MYSOL 里面拿数据,PHP把结果交给给apche ,apache 再交给用户,这样的一个过程,这种php 和 mysql 相连取数据的操作行为,叫做动态行为
访问一个网站,首先要登录,在登录的时候,这样的一个过程,在浏览器里输入网址,点登录,请求交给了apache ,apache 先检查,看下请求是动态还是静态,登录这个行为需要去把你的用户名密码提交给apache,apache拿到你的用户名密码,去数据库里面比对,看看是否正确,通过PHP模块和 mysql 去打交道,通过mysql 查到你的用户名密码是什么,然后php 做对比,看看对不对,如果对,apache 会返回给您一个登录的状态,这个过程属于一个动态的请求
动态请求 比如用户进入猿课论坛输入自己的账号密码
比如访问的图片,网站的logo,比如访问论坛的一个logo, 这个logo 也是需要到apache 上去请求的,apache拿到logo logo 它并没有存在mysql 里面 ,所以直接从静态文件这,也是就是你的linux服务器上 其中的一个目录下拿到这个图片 ,直接返回给用户,这个过程并没有和MySQL打交道,这个过程属于静态请求
静态请求,比如查看网站的图片、内容
MySQL里面不能存图片、文件, 可以存一些用户名密码,积分,回复帖子的内容
11.2 MySQL、MariaDB介绍
MySQL是一个关系型数据库,由mysql ab公司开发,mysql在2008年被sun公司收购(10亿刀),2009年sun公司被oracle公司收购(74亿刀)
MySQL官网https://www.mysql.com 最新版本5.7GA/8.0DMR
MySQL5.6变化比较大,5.7性能上有很大提升
Mariadb为MySQL的一个分支,官网https://mariadb.com/最新版本10.2
MariaDB主要由SkySQL公司(现更名为MariaDB公司)维护,SkySQL公司由MySQL原作者带领大部分原班人马创立.
Mariadb5.5版本对应MySQL的5.5,10.0对应MySQL5.6 Community 社区版本,Enterprise 企业版,GA(Generally Available)指通用版本,在生产环境中用的,DMR(Development Milestone Release)开发里程碑发布版,RC(ReleaseCandidate)发行候选版本,Beta开放测试版本,Alpha内部测试版本
11.3/11.4/11.5 MySQL安装
11.3 MySQL 安装 (上)
MySQL的几个常用安装包:rpm、源码、二进制免编译
二进制免编译(发布之前在linux服务器上租了一个编译,编译完了之后,把编译完成的文件重新安排,放到一个目录下去,然后打包压缩,发布)有一个好处,不用花那么多时间去配置,直接拿来用就可以
rpm 包有一个缺点,没有办法去定义你所安装的路径,默认就安装在/usr下
二进制免编译包可以放在一个目录下,比如说/urs/local/src下,也可以放在别的目录下,随便你自己
二进制免编译包毕竟在其他编辑器上编辑的,如果想追求极致的性能,就自己去编译
如果工作中没有特殊的要求,可以用二进制免编译包就可以。
先进入到目录 /usr/local/src
[[email protected] ~]# cd /usr/local/src/
[[email protected] src]# ls
httpd-2.4.27 httpd-2.4.27.tar.gz
用命令uname -a 查看当前系统版本,x86_64 这个是64位的
[[email protected] src]# uname -a
Linux aiker 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
[[email protected] src]#
使用wget下载
[[email protected] src]# wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.35-linux-glibc2
--2018-01-05 22:06:16-- http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_
正在解析主机 mirrors.sohu.com (mirrors.sohu.com)... 221.236.12.140
正在连接 mirrors.sohu.com (mirrors.sohu.com)|221.236.12.140|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:314581668 (300M) [application/octet-stream]
正在保存至: “mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz”
12% [============> 100%[======================================================>] 314,581,668 486KB/s 用时 18m 3s
2018-01-05 22:24:19 (284 KB/s) - 已保存 “mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz” [314581668/314581668])
[[email protected] src]#
11.4 MySQL 安装 (中)
下载完之后第一步是要解压,
[[email protected] src]# ls
httpd-2.4.27 httpd-2.4.27.tar.gz mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
[[email protected] src]# tar zxvf mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
.
.
.
mysql-5.6.35-linux-glibc2.5-x86_64/mysql-test/include/stop_slave.inc
mysql-5.6.35-linux-glibc2.5-x86_64/mysql-test/mysql-test-run.pl
mysql-5.6.35-linux-glibc2.5-x86_64/mysql-test/purify.supp
mysql-5.6.35-linux-glibc2.5-x86_64/mysql-test/valgrind.supp
挪目录到local目录下 并且改名mysql(mysql也是目录), mv /usr/local/mysql,然后到mysql目录下
[[email protected] src]# mv mysql-5.6.35-linux-glibc2.5-x86_64 /usr/local/mysql
[[email protected] src]# cd /usr/local/mysql/
[[email protected] mysql]# ls
bin data include man README share support-files
COPYING docs lib mysql-test scripts sql-bench
[[email protected] mysql]#
创建mysql用户,创建目录/data/
[[email protected] mysql]# useradd mysql
[[email protected] mysql]# mkdir /data/
mkdir: 无法创建目录"/data/": 文件已存在
[[email protected] mysql]# ls /data/
liurongluan
[[email protected] mysql]#
运行./scripts/mysql_install_db --user=mysql --datadir=/data/mysql 初始化
[[email protected] mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db:
Data::Dumper
[[email protected] mysql]#
现在报错了, please install the following Perl modules before executing 提示少了一个perl模块,名字是Dumper,尝试搜索一下
[[email protected] mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db:
Data::Dumper
[[email protected] mysql]# yum list |grep perl |grep -i dumper
perl-Data-Dumper.x86_64 2.145-3.el7 base
perl-Data-Dumper-Concise.noarch 2.020-6.el7 epel
perl-Data-Dumper-Names.noarch 0.03-17.el7 epel
perl-XML-Dumper.noarch 0.81-17.el7 base
[[email protected] mysql]#
安装第四个试下 perl-XML-Dumper
[[email protected] mysql]# yum install -y perl-XML-Dumper
已加载插件:fastestmirror
base | 3.6 kB 00:00:00
epel/x86_64/metalink
已安装:
perl-XML-Dumper.noarch 0:0.81-17.el7
作为依赖被安装:
perl-XML-Parser.x86_64 0:2.41-10.el7
完毕!
[[email protected] mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db:
Data::Dumper
[[email protected] mysql]#
还是不行,再试下第一个包 perl-Data-Dumper
[[email protected] mysql]# yum install -y perl-Data-Dumper
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* epel: mirrors.tuna.tsinghua.edu.cn
已安装:
perl-Data-Dumper.x86_64 0:2.145-3.el7
完毕!
[[email protected] mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
Installing MySQL system tables...2017-09-23 13:01:36 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-09-23 13:01:36 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2017-09-23 13:01:36 0 [Note] ./bin/mysqld (mysqld 5.6.35) starting as process 2630 ...
2017-09-23 13:01:36 2630 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-09-23 13:01:36 2630 [Note] InnoDB: The InnoDB memory heap is disabled
Support MySQL by buying support/licenses at http://shop.mysql.com
New default config file was created as ./my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings
WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server
[[email protected] mysql]#
可以了,怎么查看一个命令执行完后 是否正确? 再上一个命令运行完之后 echo $? 结果是0 就是正确的,是1就是错误的
[[email protected] mysql]# echo $?
0
[[email protected] mysql]#
初始化完成,下面就是拷贝配置文件和启动脚本,配置文件在哪?在这个目录下support-files/
[[email protected] mysql]# ls support-files/
binary-configure magic my-default.cnf mysqld_multi.server mysql-log-rotate mysql.server
[[email protected] mysql]#
[[email protected] mysql]# ls support-files/my-default.cnf
support-files/my-default.cnf
这里面大部分都是注释文件
[[email protected] mysql]# vi support-files/my-default.cnf
#For advice on how to change settings please see
#http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
#*** DO NOT EDIT THIS FILE. It‘s a template which will be copied to the
#*** default location during install, and will be replaced if you
#*** upgrade to a newer version of MySQL.
[mysqld]
#Remove leading # and set to the amount of RAM for the most important data
#cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
#innodb_buffer_pool_size = 128M
#Remove leading # to turn on a very important data integrity option: logging
#changes to the binary log between backups.
#log_bin
#These are commonly set, remove the # and set as required.
#basedir = .....
#datadir = .....
#port = .....
#server_id = .....
#socket = .....
#Remove leading # to set options mainly useful for reporting servers.
#The server defaults are faster for transactions and fast SELECTs.
#Adjust sizes as needed, experiment to find the optimal values.
"support-files/my-default.cnf" 31L, 1126C
下面就是拷贝配置文件和启动脚本
[[email protected] mysql]# cp support-files/my-default.cnf /etc/my.cnf^C
拷贝之前 也可以看下系统自带的my.cnf 文件,要用自带的my.conf 需要修改里面配置文件
[[email protected] mysql]# ls /etc/my.cnf
/etc/my.cnf
[[email protected] mysql]# rpm -qf /etc/my.cnf
mariadb-libs-5.5.52-1.el7.x86_64
[[email protected] mysql]#
[[email protected] mysql]# vim /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
#Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
#Settings user and group are ignored when systemd is used.
#If you need to run mysqld under a different user or group,
#customize your systemd unit file for mariadb according to the
#instructions in http://fedoraproject.org/wiki/Systemd
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
#
#include all files from the config directory
需要修改/etc/my.cnf 用默认的配置文件
[mysqld]
datadir=/data/mysql
socket=/tmp/mysql/mysql.sock
#Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
#Settings user and group are ignored when systemd is used.
#If you need to run mysqld under a different user or group,
#customize your systemd unit file for mariadb according to the
#instructions in http://fedoraproject.org/wiki/Systemd
[mysqld_safe]
#log-error=/var/log/mariadb/mariadb.log
#pid-file=/var/run/mariadb/mariadb.pid
#
#include all files from the config directory
#
#!includedir /etc/my.cnf.d
~
:wq
再一个就是它的启动脚本
[[email protected] mysql]# ls
bin data include man mysql-test scripts sql-bench
COPYING docs lib my.cnf README share support-files
[[email protected] mysql]#
11.5 MySQL 安装 (下)
再一个就是它的启动脚本
[[email protected] mysql]# ls
bin data include man mysql-test scripts sql-bench
COPYING docs lib my.cnf README share support-files
[[email protected] mysql]#
[[email protected] mysql]# ls support-files/
binary-configure my-default.cnf mysql-log-rotate
magic mysqld_multi.server mysql.server
把support-files/mysql.server脚本 拷贝到 改名 /etc/init.d/mysqld
[[email protected] mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[[email protected] mysql]#
[[email protected] mysql]# vi /etc/init.d/mysqld
#If you want to affect other MySQL variables, you should make your changes
#in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files.
#If you change base dir, you must also change datadir. These may get
#overwritten by settings in the MySQL configuration files.
basedir=
datadir=
-- INSERT --
改下basedir datadir
#If you change base dir, you must also change datadir. These may get
#overwritten by settings in the MySQL configuration files.
basedir=/usr/local/mysql
datadir=/data/mysql
:wq
看下权限是755
[[email protected] mysql]# vi /etc/init.d/mysqld
[[email protected] mysql]# ls -l /etc/init.d/mysqld
-rwxr-xr-x 1 root root 10902 9月 23 13:27 /etc/init.d/mysqld
[[email protected] mysql]#
如果想让它开机启动,需要把它加入到系统服务列表里去 下次开机会自动启动
[[email protected] mysql]# chkconfig --add mysqld
[[email protected] mysql]# chkconfig --list
注意:该输出结果只显示 SysV 服务,并不包含原生 systemd 服务。SysV 配置数据可能被原生 systemd 配置覆盖。
如果您想列出 systemd 服务,请执行 ‘systemctl list-unit-files‘。
欲查看对特定 target 启用的服务请执行
‘systemctl list-dependencies [target]‘。
mysqld 0:关 1:关 2:开 3:开 4:开 5:开 6:关
netconsole 0:关 1:关 2:关 3:关 4:关 5:关 6:关
network 0:关 1:关 2:开 3:关 4:关 5:关 6:关
[[email protected] mysql]#
同样的,也可以直接用命令把它启动起来
/etc/init.d/mysql start
也可以这样service mysqld start
[[email protected] mysql]# ls -l /etc/init.d/mysqld
-rwxr-xr-x 1 root root 10875 9月 23 18:13 /etc/init.d/mysqld
[[email protected] mysql]# chmod 755 /etc/init.d/mysqld
[[email protected] mysql]# vim /etc/init.d/mysqld
[[email protected] mysql]# chkconfig --add mysqld
[[email protected] mysql]# chkconfig mysqld on
[[email protected] mysql]# service mysqld start
Starting MySQL.Logging to ‘/data/mysql/aiker.err‘.
.. SUCCESS!
[[email protected] mysql]#
查看下服务 是否有,看下进程
[[email protected] mysql]# ps aux |grep mysql
root 6110 0.0 0.1 11764 1580 pts/0 S 18:15 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/aiker.pid
mysql 6320 0.8 45.6 973052 456580 pts/0 Sl 18:15 0:01 /usr/local/mysq/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/aiker.err --pid-file=/data/mysql/aiker.pid --socket=/tmp/mysql.sock --port=3306
root 6386 0.0 0.0 112664 976 pts/0 S+ 18:19 0:00 grep --color=auto mysql
[[email protected] mysql]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1131/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1648/master
tcp6 0 0 :::3306 :::* LISTEN 6320/mysqld
tcp6 0 0 :::22 :::* LISTEN 1131/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1648/master
[[email protected] mysql]#
如果说有一天你没有办法把启动脚本放到/etc/init.d/ 下去,或者说你根本就没有这样的启动模板去拷贝,可以用这种方法去启动
首先我们先给mysqld 停掉
[[email protected] mysql]# service mysqld stop
Shutting down MySQL.. SUCCESS!
[[email protected] mysql]# !ps
ps aux |grep mysql
root 6427 0.0 0.0 112664 972 pts/0 S+ 18:23 0:00 grep --color=auto mysql
使用这种方法命令行的方式启动
[[email protected] mysql]# /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql --datadir=/data/mysql &
[2] 6716
[1] 完成 /usr/local/mysql/bin/mysqld_safe --default-file=/etc/my.cnf --user=mysql --datadir=/data/mysql
[[email protected] mysql]# 170923 18:28:43 mysqld_safe Logging to ‘/data/mysql/aiker.err‘.
170923 18:28:43 mysqld_safe Starting mysqld daemon with databases from /data/mysql
[[email protected] mysql]#
[[email protected] mysql]# ps aux |grep mysql
root 6716 0.0 0.1 113256 1584 pts/0 S 18:28 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql --datadir=/data/mysql
mysql 6914 0.5 45.4 973052 454888 pts/0 Sl 18:28 0:00 /usr/local/mysql/binmysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/aiker.err --pid-file=/data/mysql/aiker.pid --socket=/tmp/mysql.sock --port=3306
root 6937 0.0 0.0 112664 976 pts/0 S+ 18:29 0:00 grep --color=auto mysql
[[email protected] mysql]#
[[email protected] mysql]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1131/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1648/master
tcp6 0 0 :::3306 :::* LISTEN 6914/mysqld
tcp6 0 0 :::22 :::* LISTEN 1131/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1648/master
[[email protected] mysql]#
那怎么去关呢,可以用killall mysqld 命令 把这个服务停掉
[[email protected] mysql]# killall mysqld
[[email protected] mysql]# 170923 18:32:07 mysqld_safe mysqld from pid file /data/mysql/aiker.pid ended
[[email protected] mysql]# !ps
ps aux |grep mysql
root 6950 0.0 0.0 112664 976 pts/0 R+ 18:32 0:00 grep --color=auto mysq
[2]+ 完成 /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf
[[email protected] mysql]#
建议大家用killall 安全一些,先停止当前的写读操作,把那些没有完成磁盘写入的数据写到磁盘里去,知道写完之后 才把进程杀死,
如果以后遇到 mysqld 的进程 适中杀不死,等了好久没有把进程杀死ps 还有进程,那说明你的数据量很大,正在慢慢的写入磁盘离去,不要强制用kill ,很容易导致数据丢失,就慢慢的等就好了,
mysql 有俩个引擎 一个是innodb 一个是 myisam(存储量比较小)
扩展
mysql5.5源码编译安装
MYSQL5.5源码安装 linux下 ,首先安装必要的库
yum -y install gcc*
安装 MYSQL
首先安装camke
一、支持YUM,则
yum install -y cmake
二、也可以源码安装
cd /usr/local/src
#下载cmake
wget http://www.cmake.org/files/v2.8/cmake-2.8.7.tar.gz
tar zxvf cmake-2.8.7.tar.gz
cd cmake-2.8.7
#安装cmake
./configure
make
make install
安装 MYSQL
官网下载 MYSQL5.5版本 linux下源码包
http://dev.mysql.com/downloads/
安装
groupadd mysql
useradd -g mysql mysql
tar zxvf mysql-5.2.25.tar.gz
cd mysql-5.2.25
#cmake .
//默认情况下安装,安装目录为/usr/local/mysql 数据目录为/usr/local/mysql/data
#也可以指定参数安装,如指定UTF8,数据引擎等
#具体参照http://dev.mysql.com/doc/refman/ ... ration-options.html
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=all -DWITH_DEBUG=0 -DWITH_SSL=yes -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1
make && make install
cd /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql
./scripts/mysql_install_db --user=mysql -datadir=/mysql/data
#此处如不指定datadir,到启动时会报错
chown -R root .
chown -R mysql data
cp support-files/my-medium.cnf /etc/my.cnf
bin/mysqld_safe --user=mysql &
#Next command is optional
cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
/etc/init.d/mysqld start
到此,安装完成
mysql5.7二进制包安装(变化较大)
mysql5.7 二进制包安装
- 下载包
wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz
若该链接失效,请到r.aminglinux.com 找最新的下载地址。
- 解压
tar xxvf mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.7.12-linux-glibc2.5-x86_64 /usr/local/mysql
3. 初始化
useradd -M -s /sbin/nologin mysql
mkdir -p /data/mysql
chown mysql /data/mysql
cd /usr/local/mysql
./bin/mysqld --initialize --user=mysql --datadir=/data/mysql
注意,这一步最后一行会有一个提示
[Note] A temporary password is generated for [email protected]:xxxxxxx
最后面的字符串为root密码。
./bin/mysql_ssl_rsa_setup --datadir=/data/mysql
4. 拷贝配置文件和启动脚本
cp support-files/my-default.cnf /etc/my.cnf
`vim /etc/my.cnf` //编辑或者修改
basedir = /usr/local/mysql
datadir = /data/mysql
port = 3306
socket = /tmp/mysql.sock
cp support-files/mysql.server /etc/init.d/mysqld
`vi /etc/init.d/mysqld` //编辑或者修改
basedir=/usr/local/mysql
datadir=/data/mysql
5. 启动服务
/etc/init.d/mysqld start
6. 设置root密码
使用初始化密码登录
`/usr/local/mysql/bin/mysql -uroot -pxxxxxxx` //进入后直接设置密码
`mysql>set password = password(‘mypass‘); ` //一定要设置一下新密码
退出来,再使用新的密码登录就可以了
还有一种情况,就是不知道初始化密码
vi /etc/my.cnf
在[mysqld]下面增加一行
`skip-grant-tables`
重启 ` /etc/init.d/mysqld restart`
/usr/local/mysql/bin/mysql -uroot
mysql> update user set authentication_string=password(‘12345678‘) where user=‘root‘;
退出来后,更改my.cnf,去掉刚加的 `skip-grant-tables`
重启` /etc/init.d/mysqld restart`
此时就可以使用新的密码了。
以上是关于九周第四次课的主要内容,如果未能解决你的问题,请参考以下文章
九周第四次课(2月26日) 11.1 LAMP架构介绍 11.2 MySQLMariaDB介绍 11.3/11.4/11.5 MySQL安装 扩展 mysql5.5源码编译安装