MySQL学习第一弹:mysql安装
来源:互联网 发布:mac图片浏览器 下一张 编辑:程序博客网 时间:2024/05/22 01:30
一、 前言
1. MySQL几种发布形式:
GA(General Availability):发行版本
RC(Release Candidate):发行候选
bate:公测
alpha:内测
2. Mysql的包(红色的必须装):
MySQL-client-advanced-5.6.25-1.el6.x86_64.rpm —— 客户端工具
MySQL-devel-advanced-5.6.25-1.el6.x86_64.rpm —— 开发组件(头文件库文件,针对mysql)
MySQL-embedded-advanced-5.6.25-1.el6.x86_64.rpm ——嵌入式环境使用的
MySQL-server-advanced-5.6.25-1.el6.x86_64.rpm ——服务器端
MySQL-shared-advanced-5.6.25-1.el6.x86_64.rpm ——共享库
MySQL-shared-compat-advanced-5.6.25-1.el6.x86_64.rpm ——兼容库,是shared的补充
MySQL-test-advanced-5.6.25-1.el6.x86_64.rpm ——Mysql测试组件
其他还有:
MySQL-debuginfo ——调试包
MySQL-ndb-management ——cluster用,namedb组件
3. Mysql目录结构:
bin:所有二进制程序
lib:库文件
data:默认数据目录
include:头文件
man:手册
mysql-test:测试组件
scripts:脚本目录至存放了初始化脚本
share:存放不同语言的错误信息
sql-bench:存放MySQL基准性能测试的工具包
support-files:存放很多脚本
MySQL如何初始化配置:
4. 服务器端会找my.cnf中心配置文件,查找顺序如下:
linux:
/etc/my.cnf
/etc/mysql/my.cnf
/$MYSQL_HOME/my.cnf
defaults-extra-file=/path/to/file
~/.my.cnf
如果多个文件都存在,则合起来的结果为最终结果,如果结果重复,则最后一次读取的配置将会生效。在启动mysql的时候可以使用mysql_safe defaults-extra-file=/path/to/file来指定。
windows:
%WINDIR%\my.ini, %WINDIR%\my.cnf
C:\my.ini, C:\my.cnf
%INSTALLDIR%\my.ini, %INSTALLDIR%\my.cnf
defaults-extra-file=/path/to/file
二、 mysql安装完成需要的操作:
1. rpm安装方式
只需要安装上述您所需要的包
2. 源码安装方式(查看)
[root@localhostmysql]# cd /usr/local
[root@localhostmysql]# > tar zxvf /path/to/mysql-VERSION-OS.tar.gz
[root@localhostmysql]# > ln -s full-path-to-mysql-VERSION-OS mysql
[root@localhostmysql]# groupadd mysql
[root@localhostmysql]# useradd -r -g mysql mysql
[root@localhostmysql]# chown -R mysql .
[root@localhostmysql]# chgrp -R mysql .
[root@localhostmysql]# ./scripts/mysql_install_db --user=mysql
Installing MySQL system tables...2015-06-1616:33:25 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated.Please use --explicit_defaults_for_timestamp server option (see documentationfor more details).
2015-06-16 16:33:25 45796 [Note] InnoDB: TheInnoDB memory heap is disabled
2015-06-16 16:33:25 45796 [Note] InnoDB:Mutexes and rw_locks use GCC atomic builtins
2015-06-16 16:33:25 45796 [Note] InnoDB:Compressed tables use zlib 1.2.3
2015-06-16 16:33:25 45796 [Note] InnoDB:Using Linux native AIO
2015-06-16 16:33:25 45796 [Note] InnoDB:Using CPU crc32 instructions
2015-06-16 16:33:25 45796 [Note] InnoDB:Initializing buffer pool, size = 128.0M
2015-06-16 16:33:25 45796 [Note] InnoDB:Completed initialization of buffer pool
2015-06-16 16:33:25 45796 [Note] InnoDB:The first specified data file ./ibdata1 did not exist: a new database to becreated!
2015-06-16 16:33:25 45796 [Note] InnoDB:Setting file ./ibdata1 size to 12 MB
2015-06-16 16:33:25 45796 [Note] InnoDB:Database physically writes the file full: wait...
2015-06-16 16:33:25 45796 [Note] InnoDB:Setting log file ./ib_logfile101 size to 48 MB
2015-06-16 16:33:26 45796 [Note] InnoDB:Setting log file ./ib_logfile1 size to 48 MB
2015-06-16 16:33:26 45796 [Note] InnoDB:Renaming log file ./ib_logfile101 to ./ib_logfile0
2015-06-16 16:33:26 45796 [Warning] InnoDB:New log files created, LSN=45781
2015-06-16 16:33:26 45796 [Note] InnoDB:Doublewrite buffer not found: creating new
2015-06-16 16:33:26 45796 [Note] InnoDB:Doublewrite buffer created
2015-06-16 16:33:26 45796 [Note] InnoDB:128 rollback segment(s) are active.
2015-06-16 16:33:26 45796 [Warning] InnoDB:Creating foreign key constraint system tables.
2015-06-16 16:33:26 45796 [Note] InnoDB:Foreign key constraint system tables created
2015-06-16 16:33:26 45796 [Note] InnoDB:Creating tablespace and datafile system tables.
2015-06-16 16:33:26 45796 [Note] InnoDB:Tablespace and datafile system tables created.
2015-06-16 16:33:26 45796 [Note] InnoDB:Waiting for purge to start
2015-06-16 16:33:26 45796 [Note] InnoDB:5.6.12 started; log sequence number 0
2015-06-16 16:33:26 45796 [Note] Binlog end
2015-06-16 16:33:26 45796 [Note] InnoDB:FTS optimize thread exiting.
2015-06-16 16:33:26 45796 [Note] InnoDB:Starting shutdown...
2015-06-16 16:33:28 45796 [Note] InnoDB:Shutdown completed; log sequence number 1625977
OK
Filling help tables...2015-06-16 16:33:28 0[Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use--explicit_defaults_for_timestamp server option (see documentation for moredetails).
2015-06-16 16:33:28 45819 [Note] InnoDB:The InnoDB memory heap is disabled
2015-06-16 16:33:28 45819 [Note] InnoDB:Mutexes and rw_locks use GCC atomic builtins
2015-06-16 16:33:28 45819 [Note] InnoDB:Compressed tables use zlib 1.2.3
2015-06-16 16:33:28 45819 [Note] InnoDB:Using Linux native AIO
2015-06-16 16:33:28 45819 [Note] InnoDB:Using CPU crc32 instructions
2015-06-16 16:33:28 45819 [Note] InnoDB:Initializing buffer pool, size = 128.0M
2015-06-16 16:33:28 45819 [Note] InnoDB:Completed initialization of buffer pool
2015-06-16 16:33:28 45819 [Note] InnoDB:Highest supported file format is Barracuda.
2015-06-16 16:33:28 45819 [Note] InnoDB:128 rollback segment(s) are active.
2015-06-16 16:33:28 45819 [Note] InnoDB:Waiting for purge to start
2015-06-16 16:33:28 45819 [Note] InnoDB:5.6.12 started; log sequence number 1625977
2015-06-16 16:33:28 45819 [Note] Binlog end
2015-06-16 16:33:28 45819 [Note] InnoDB:FTS optimize thread exiting.
2015-06-16 16:33:28 45819 [Note] InnoDB:Starting shutdown...
2015-06-16 16:33:30 45819 [Note] InnoDB:Shutdown completed; log sequence number 1625987
OK
To start mysqld at boot time you have tocopy
support-files/mysql.server to the rightplace for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THEMySQL root USER !
To do so, start the server, then issue thefollowing commands:
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h localhost.localdomain password'new-password'
Alternatively you can run:
./bin/mysql_secure_installation
which will also give you the option ofremoving the test
databases and anonymous user created bydefault. This is
strongly recommended for productionservers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd. ; ./bin/mysqld_safe &
You can test the MySQL daemon withmysql-test-run.pl
cdmysql-test ; perl mysql-test-run.pl
Please report any problems with the./bin/mysqlbug script!
The latest information about MySQL isavailable on the web at
http://www.mysql.com
Support MySQL by buying support/licenses athttp://shop.mysql.com
New default config file was created as./my.cnf and
will be used by default by the server whenyou start it.
You may edit this file to change serversettings
WARNING: Default config file /etc/my.cnfexists on the system
This file will be read by default by theMySQL server
If you do not want to use this, eitherremove it, or use the
--defaults-file argument to mysqld_safewhen starting the server
[root@localhostmysql]# chown -R root .
[root@localhostmysql]# chown -R mysql data
[root@localhostmysql]# cp support-files/my-default.cnf /etc/my.cnf
cp:是否覆盖"/etc/my.cnf"? y
[root@localhost mysql]#chkconfig --addmysqld
[root@localhostmysql]#chkconfig mysqld on
3. 将mysql程序加入到服务列表
[root@localhostmysql]#cp support-files/mysql.server /etc/init.d/mysqld
[root@localhostmysql]#chkconfig --add mysqld
[root@localhostmysql]#chkconfig mysqld on
三、 mysql安装后需要做的工作
1. mysql安装一般会产生5个用户,并且没有设置密码
root@127.0.0.1
root@hostname
root@localhost
‘’@localhost
‘’@hostname
2. 删除匿名用户:
mysql>DROP USER ''@localhost;
Query OK, 0 rows affected (0.00 sec)
mysql>drop user ""@localhost.localdomain;
Query OK, 0 rows affected (0.00 sec)
删除IPV6的root用户
mysql>drop user 'root'@'::1';
Query OK, 0 rows affected (0.00 sec)
3. 给管理员加密码:
mysql>UPDATE user SET PASSWORD=PASSWORD('bzfys') WHERE user='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0
mysql>FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
4. 查看用户信息
mysql>select user,host,password from user;
+------+-----------------------+-------------------------------------------+
| user | host | password |
+------+-----------------------+-------------------------------------------+
| root | localhost |*4941369BD46398A2BDEEC85411065D7137D4EA0F |
| root | localhost.localdomain |*4941369BD46398A2BDEEC85411065D7137D4EA0F |
| root | 127.0.0.1 |*4941369BD46398A2BDEEC85411065D7137D4EA0F |
+------+-----------------------+-------------------------------------------+
3 rows in set (0.00 sec)
四、 维护mysql(注意前面我把mysql程序设为mysqld)
1. 启动mysql
[root@localhostmysql]# /etc/init.d/mysqld start
Starting MySQL.....[确定]
2. 查看mysql进程
[root@localhost bin]# ps -ef|grep mysql
root 18910 1 0 09:54 pts/1 00:00:00 /bin/sh /usr/bin/mysqld_safe--datadir=/var/lib/mysql --pid-file=/var/lib/mysql/localhost.localdomain.pid
mysql 19086 18910 19 09:54 pts/1 00:00:03 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql--plugin-dir=/usr/lib64/mysql/plugin --user=mysql--log-error=/var/log/mysqld.log--pid-file=/var/lib/mysql/localhost.localdomain.pid --socket=/var/lib/mysql/mysql.sock
3. 关闭mysql
[root@localhost bin]# service mysqld start
Starting MySQL..[确定]
郑重申明:由于本人技术有限,如有错误请大神们更正(327568824@qq.com)
- MySQL学习第一弹:mysql安装
- Mysql学习第一课
- MySql笔记(第一弹:MySql的安装)
- mysql学习之一:mysql安装
- Linux学习---mysql安装
- MySQL学习记录--安装
- mysql官方源码安装第一部分
- MYSQL第一谈:ubuntu下如何安装MYSQL
- MySQL学习---->第一练:语句入门、数据类型
- Mysql学习第一课-mysql的定义及sql语句
- MySQL学习笔记03-MySQL的安装
- MySQL学习笔记之二 MySQL安装
- MySQL——学习开始(MySQL安装)
- Mysql++学习(一)------mysql编译安装
- MySQL学习——MySQL安装
- MySQL学习【1】MySQL安装与配置
- Mysql学习-Linux Mysql源码编译安装
- MySQL学习第二篇:MySQL安装
- 接着刷题
- Android bluetooth 蓝牙开发/蓝牙协议/蓝牙通信
- java取整和java四舍五入方法
- 【转载】恼人的函数指针(一)
- leetcode 4 -- Median of Two Sorted Arrays
- MySQL学习第一弹:mysql安装
- 中国大陆新身份证号码算法[18位身份证号码生成器]
- Frostwire工程项目的建立
- [翻译]Swift编程语言——基础
- OpenCV中的HOG+SVM物体分类
- 走进Struts2(三)— 验证器
- 第七题
- C#多线程编程
- 【C++ Primer Plus 9.3】名称空间