mysql镜像下载地址http://dev.mysql.com/downloads/mirrors.html
mysql二进制包下载地址http://dev.mysql.com/downloads/mysql/
MySQL是一个关系型数据库管理系统,开发者为瑞典MySQLAB公司
关系型数据库将数据保存在不同的表中,而不是将所有数据放在一个大仓库内。
这样就增加了速度并提高了灵活性。
SQL是用于访问数据库的标准化语言
MySQL采用GPL(GNU通用公共许可证)。
由于其体积小、速度快、总体拥有成本低,尤其是开放源码这一特点,许多中小型网站为了降低网站总体拥有成本而选择了MySQL作为网站数据库
安装和配置mysql的rpm软件包
yum install mysql* -y
查看软件包
[iyunv@localhost yum.repos.d]# rpm -qa | grep mysql
mysql-test-5.1.61-4.el6.i686
mysql-bench-5.1.61-4.el6.i686
mysql-5.1.61-4.el6.i686 (客户端软件包)
mysql-connector-java-5.1.17-6.el6.noarch
mysql-connector-odbc-5.1.5r1144-7.el6.i686
mysql-devel-5.1.61-4.el6.i686(开发工具软件包)
mysql-server-5.1.61-4.el6.i686 (服务器软件包)
mysql-libs-5.1.61-4.el6.i686 (开发库软件包)
安装好多需的包后,直接启动就可以了,初次启动会看到数据库初始化的情况
[iyunv@localhost yum.repos.d]# /etc/init.d/mysqld start
初始化 MySQL 数据库: Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/bin/mysqlbug script!
[确定]
正在启动 mysqld: [确定]
rpm包配置文件的位置及其默认配置
[iyunv@localhost yum.repos.d]# cat /etc/my.cnf
[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@localhost yum.repos.d]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
原因:是使用了[iyunv@localhost yum.repos.d]# /usr/bin/mysqladmin -u root password 'aixocm'
设置了密码
解决:
[iyunv@localhost yum.repos.d]# mysql -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.1.61 Source distribution
Copyright (c) 2000, 2011, 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>
mysql源码安装
需要下载mysql-5.6.11.tar.gz压缩包
1.解压
tar xvf mysql-5.6.11.tar.gz
2.进入解压后的目录
cd mysql-5.6.11
yum安装cmake,make,gcc
yum install cmake -y
yum install make -y
yum install gcc*
3.之后就编译(注意大小写不能有错)
cmake \
-DCMAKE_INSTALL_PREFIX:PATH=/usr/local/mysql56 \---》指定安装路径
-DMYSQL_DATADIR:PATH=/database56 \
-DWITH_DEBUG:BOOL=ON \ ---》支持调试
-DWITH_EXTRA_CHARSETS:STRING=all \ ---》支持字符集
-DWITH_INNOBASE_STORAGE_ENGINE:BOOL=ON \
-DWITH_PARTITION_STORAGE_ENGINE:BOOL=ON
4.make && make install ---》完成到这
5.安装后进入安装目录
cd /usr/local/mysql56
mkdir etc
新建文件etc,用来存放MySQL的配置文件my.cnf
cd etc
新建my.cnf文件,可以从已经安装好的MySQL拷贝一份进行修改
my.cnf文件的内容(/usr/local/mysql56/etc/my.cnf):
[mysqld]
basedir=/usr/local/mysql56
datadir=/database56
socket=/var/run/mysqld/mysql56.sock
pid-file=/var/run/mysqld/mysql56.pid
port=3307
user=mysql
[mysqld_safe]
log-error=/var/log/mysql/mysqld57.log
以上my.cnf中用到的文件夹根据需要进行建立
mkdir /database56
mkdir /var/log/mysql
mkdir /var/run/mysqld
修改目录及其中文件的属主与属组
chown mysql:mysql /usr/local/mysql56 /var/log/mysql /var/run/mysqld -R
初始化启动所需数据库
cd /usr/local/mysql56/scripts
./mysql_install_db --basedir=/usr/local/mysql56 --datadir=/database56 --user=mysql
复制服务文件并修改
cp /usr/local/mysql56/support-files/mysql.server /etc/rc.d/init.d/mysql56
vim /etc/rc.d/init.d/mysql56
修改conf=/usr/local/mysql56/etc/my.cnf
添加服务到自启动项
chkconfig --list mysql56
chkconfig mysql56 on
启动mysql服务
service mysql56 start 启动
service mysql56 status 查看状态
service mysql56 stop 关闭
启动mysql客户端
mysql -S /var/run/mysqld/mysql56.sock
修改 /etc/my.cnf文件中的[mysql]段
做为MySQL客户端程序的配置文件
/etc/init.d -> rc.d/init.d
netstat -ntaup | grep "mysql"
ps -aux | grep "mysql" | grep ".sock" --color
出现错误
-- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake/readline.cmake:82 (MESSAGE):
Curses library not found. Please install appropriate package,
remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
Call Stack (most recent call first):
cmake/readline.cmake:126 (FIND_CURSES)
cmake/readline.cmake:216 (MYSQL_USE_BUNDLED_LIBEDIT)
CMakeLists.txt:250 (MYSQL_CHECK_READLINE)
-- Configuring incomplete, errors occurred!
解决:
[iyunv@localhost mysql-5.5.11]# rm -rf CMakeCache.txt
[iyunv@localhost mysql-5.5.11]# yum install ncurses-devel
Warning: Bison executable not found in PATH
-- Configuring done
-- Generating done
-- Build files have been written to: /software/mysql-5.5.11
[iyunv@localhost mysql-5.5.11]# yum install bison
|