1.操作系统:CentOS
2.数据库: mysql-5.1.73.tar.gz
3.任务:单实例安装配置指南
提示:下载数据库有两种方式:一种是官网,另一种途径是国内镜象网站;国内镜象下载资源的速度比官网要快,例如,我们这次下载的就是国内搜狐镜象:
http://mirrors.sohu.com/mysql/MySQL-5.1/
http://mirrors.sohu.com/
整个安装过程:
[root@localhost tools]#wget http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.73.tar.gz
[root@localhost tools]# tar zxf mysql-5.1.73.tar.gz
[[email protected]]# ./configure \
>--prefix=/usr/local/mysql \ #设定mysql安装路径,默认为/usr/local
>--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock \ #指定mysql socket文件存放目录
>--localstatedir=/usr/local/mysql/data \ #设定mysql的文件存放位置
>--enable-assembler \ #充许使用汇编模式(优化性能)
>--enable-thread-safe-client \ #服务器
>--with-mysqld-user-user=mysql \
>--with-big-tables \
>--without-debug \ #使用非debug模式
>--with-pthread \ #强制使用pthread线程序库编译
>--enable-assembler \
>--with-extra-charsets=complex \
>--with-readline \
>--with-ssl \
>--with-embedded-server \
>--enable-local-infile \
>--with-plugins=partition,innobase \
>--with-plugin-PLUGIN \
>--with-mysqld-ldflags=-all-static \ #服务器使用静态库(优化性能)
>--with-client-ldflags=-all-static #客户端使用静态库
#安装过程中报了一些错误
……………………………………………………………………..
checkingfor int8... no
checkingfor uint8... no
checkingfor int16... no
checkingfor uint16... no
checkingfor int32... no
checkingfor uint32... no
checkingfor int64... no
checkingfor uint64... no
checkingfor uchar... no
checkingcurses.h usability... no
checkingcurses.h presence... no
checkingfor curses.h... no
checkingtermcap.h usability... no
checkingtermcap.h presence... no
checkingfor termcap.h... no
checkingfor tgetent in -lncursesw... no
checkingfor tgetent in -lncurses... no
checkingfor tgetent in -lcurses... no
checkingfor tgetent in -ltermcap... no
checkingfor tgetent in -ltinfo... no
checkingfor termcap functions library... configure: error: No curses/termcap libraryfound
………………………………………………………….
# 解决以上方式(CentOS)的错误:
[root@localhosttools]# yum -y install ncurses-devel
[root@localhosttools]# yum install gcc gcc-c++
#接下来重新配置环境;
[[email protected]]# ./configure \
#显示如下信息,说明配置环境成功
Thank you for choosing MySQL!
Remember to check the platform specific part of the reference manual
for hints about installing MySQL on your platform.
Also have a look at the files in the Docs directory.
[[email protected]]# make #编译
[[email protected]]#make install #执行安装
#安装完成之后,就要检查安装是否成功!
[root@localhostmysql]# /etc/init.d/mysqld start
[root@localhostmysql]# netstat -lnt|grep 3306 #检查3306端口是否开启了
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
root@localhostmysql]# mysql -u root -p
Enterpassword:
ERROR1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
#登录不了的解决办法如下:
[root@localhost~]#sudo /etc/init.d/mysqld stop
[root@localhost~]#mysqld_safe --skip-grant-tables&
[root@localhost~]# mysql -u root mysql
mysql>update user set password=PASSWORD("设置新密码") where user='root';
mysql>flush privileges; //刷新系统权限表,立即生效
补充资料:
1)从本地上传资源到远程服务器:
[root@localhost tools]# rz #结合secureCRT工具,通过rz命令,把资源上传到服务器上也可以
[root@localhost tools]# yum install lrzsz -y #没有安装,通过该yum源安装
2)单实例登录mysql方法:
[root@localhost tools]#mysql #刚安装完无密码情况登录方式
[root@localhost tools]# mysql -uroot #刚安装系统无密码情况登录方式
[root@localhost tools]#mysql -uroot -p #这里标准的dab命令行登录命令
[root@localhost tools]#mysql -uroot -p'sky' #非脚本里一般不这用,明文使用不安全
3)登录成功后显示的信息:
[root@localhost /]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g. #命令以分号';'或'\g'结束;
Your MySQL connection id is 8
Server version: 5.1.73 Source distribution #显示mysql的版本信息
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 i #帮助提示;
4)退出mysql方法:
mysql>exit或quit