安装环境
centos6.5 win7虚拟机安装
当前centos 版本与redhat对应的版本
安装mysql
一、mysql下载地址:
http://dev.mysql.com/downloads/mysql/
下载成功 对于的内容:MySQL-5.6.28-1.linux_glibc2.5.x86_64.rpm-bundle.tar
二、解压:命令:tar -xvf MySQL-5.6.28-1.linux_glibc2.5.x86_64.rpm-bundle.tar
三、安装
3.1、检查系统是不是已经安装了mysql
执行命令:
bigdata@vip ~/soft/mysql :rpm -qa | grep mysql
如果存在的话 ---卸载 rpm -e --nodeps mysql-libs-5.1.61-4.el6.x86_64
(--nodesp 代表不管依赖关系 强制卸载)
3.2 执行安装
MySQL-server-5.6.28-1.linux_glibc2.5.x86_64.rpm和MySQL-client-5.6.28-1.linux_glibc2.5.x86_64.rpm
官网文档这么描述的 (执行一个标准的最小安装 ,只需要安装server和client)
To perform a standard minimal installation, install the server and client RPMs:
rpm -i MySQL-server-VERSION.linux_glibc2.5.i386.rpm
VERSION
rpm -i MySQL-client-VERSION.linux_glibc2.5.i386.rpm
VERSION
切换到root用户 执行安装
root@vip /bigdata/soft/mysql :rpm -ivh MySQL-server-5.6.28-1.linux_glibc2.5.x86_64.rpm root@vip /bigdata/soft/mysql :rpm -ivh MySQL-client-5.6.28-1.linux_glibc2.5.x86_64.rpm
四、启动mysql
查看MySQL运行状态的方法:
root@vip /etc/init.d :./mysql status;
MySQL running (15911) [确定]
root@vip /etc/init.d :
五、登录mysqlroot@vip /etc/init.d :mysql -u root -p
=========往往安装没有上面顺利下面是我安装遇到的问题及解决===================
三.error 执行安装
执行rpm MySQL-server-5.6.28-1.linux_glibc2.5.x86_64.rpm
rpm -ivh --prefix(我指定安装到/usr/lib目录结果出现了错误error: package MySQL-server is not relocatable 提示我们不能指定目录)
root@vip /bigdata/soft/mysql :rpm -ivh --prefix=/usr/lib MySQL-server-5.6.28-1.linux_glibc2.5.x86_64.rpm
warning: MySQL-server-5.6.28-1.linux_glibc2.5.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: package MySQL-server is not relocatable
root@vip /bigdata/soft/mysql :
重新执行命令:rpm -ivh MySQL-server-5.6.28-1.linux_glibc2.5.x86_64.rpm(可以看到打印的具体日志 我们没有创建mysql 用户 --安装程序用来root ,我后面又重新卸载了mysql 创建一个用户进行安装 结果失败·· 因为rpm 安装程序默认会跑到其他目录进行写入文件 /use/lib..... 所以可定是没有权限··error: can't create transaction lock on /var/lib/rpm/.rpm.lock (权限不够))
root@vip /bigdata/soft/mysql :rpm -ivh MySQL-server-5.6.28-1.linux_glibc2.5.x86_64.rpm
warning: MySQL-server-5.6.28-1.linux_glibc2.5.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:MySQL-server ########################################### [100%]
warning: user mysql does not exist - using root
warning: group mysql does not exist - using root
2016-01-09 17:38:25 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-01-09 17:38:25 0 [Note] /usr/sbin/mysqld (mysqld 5.6.28) starting as process 14272 ...
2016-01-09 17:38:25 14272 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-01-09 17:38:25 14272 [Note] InnoDB: The InnoDB memory heap is disabled
2016-01-09 17:38:25 14272 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-01-09 17:38:25 14272 [Note] InnoDB: Memory barrier is not used
2016-01-09 17:38:25 14272 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-01-09 17:38:25 14272 [Note] InnoDB: Using Linux native AIO
2016-01-09 17:38:25 14272 [Note] InnoDB: Not using CPU crc32 instructions
2016-01-09 17:38:26 14272 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-01-09 17:38:26 14272 [Note] InnoDB: Completed initialization of buffer pool
2016-01-09 17:38:26 14272 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2016-01-09 17:38:26 14272 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2016-01-09 17:38:26 14272 [Note] InnoDB: Database physically writes the file full: wait...
2016-01-09 17:38:26 14272 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2016-01-09 17:38:27 14272 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2016-01-09 17:38:28 14272 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2016-01-09 17:38:28 14272 [Warning] InnoDB: New log files created, LSN=45781
2016-01-09 17:38:28 14272 [Note] InnoDB: Doublewrite buffer not found: creating new
2016-01-09 17:38:28 14272 [Note] InnoDB: Doublewrite buffer created
2016-01-09 17:38:28 14272 [Note] InnoDB: 128 rollback segment(s) are active.
2016-01-09 17:38:28 14272 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-01-09 17:38:28 14272 [Note] InnoDB: Foreign key constraint system tables created
2016-01-09 17:38:28 14272 [Note] InnoDB: Creating tablespace and datafile system tables.
2016-01-09 17:38:28 14272 [Note] InnoDB: Tablespace and datafile system tables created.
2016-01-09 17:38:28 14272 [Note] InnoDB: Waiting for purge to start
2016-01-09 17:38:28 14272 [Note] InnoDB: 5.6.28 started; log sequence number 0
A random root password has been set. You will find it in '/root/.mysql_secret'.
2016-01-09 17:38:29 14272 [Note] Binlog end
2016-01-09 17:38:29 14272 [Note] InnoDB: FTS optimize thread exiting.
2016-01-09 17:38:29 14272 [Note] InnoDB: Starting shutdown...
2016-01-09 17:38:30 14272 [Note] InnoDB: Shutdown completed; log sequence number 1625977
2016-01-09 17:38:30 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-01-09 17:38:30 0 [Note] /usr/sbin/mysqld (mysqld 5.6.28) starting as process 14295 ...
2016-01-09 17:38:30 14295 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-01-09 17:38:30 14295 [Note] InnoDB: The InnoDB memory heap is disabled
2016-01-09 17:38:30 14295 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-01-09 17:38:30 14295 [Note] InnoDB: Memory barrier is not used
2016-01-09 17:38:30 14295 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-01-09 17:38:30 14295 [Note] InnoDB: Using Linux native AIO
2016-01-09 17:38:30 14295 [Note] InnoDB: Not using CPU crc32 instructions
2016-01-09 17:38:30 14295 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-01-09 17:38:30 14295 [Note] InnoDB: Completed initialization of buffer pool
2016-01-09 17:38:30 14295 [Note] InnoDB: Highest supported file format is Barracuda.
2016-01-09 17:38:30 14295 [Note] InnoDB: 128 rollback segment(s) are active.
2016-01-09 17:38:30 14295 [Note] InnoDB: Waiting for purge to start
2016-01-09 17:38:30 14295 [Note] InnoDB: 5.6.28 started; log sequence number 1625977
2016-01-09 17:38:31 14295 [Note] Binlog end
2016-01-09 17:38:31 14295 [Note] InnoDB: FTS optimize thread exiting.
2016-01-09 17:38:31 14295 [Note] InnoDB: Starting shutdown...
2016-01-09 17:38:32 14295 [Note] InnoDB: Shutdown completed; log sequence number 1625987
A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
You will find that password in '/root/.mysql_secret'.
You must change that password on your first connect,
no other statement but 'SET PASSWORD' will be accepted.
See the manual for the semantics of the 'password expired' flag.
Also, the account for the anonymous user has been removed.
In addition, you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test database.
This is strongly recommended for production servers.
See the manual for more instructions.
Please report any problems at http://bugs.mysql.com/
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
New default config file was created as /usr/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings
root@vip /bigdata/soft/mysql :
四.error 启动mysql
root@vip / :mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
root@vip / :mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
出现这种问题首先停止mysql
root@vip / :/etc/init.d/mysql stop
Shutting down MySQL.. [确定]
然后使用mysqld_safe命令在启动mysql,更新root账号的密码
--skip-grant-tables:不启动grant-tables(授权表),跳过权限控制。
--skip-networking :跳过TCP/IP协议,只在本机访问(这个选项不是必须的。可以不用)
执行命令:mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
root@vip / :mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
[1] 15589
root@vip / :160109 22:33:02 mysqld_safe Logging to '/var/lib/mysql/vip.err'.
160109 22:33:02 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
以root用户登录mysql- 执行命令:mysql -u root mysql
root@vip / :mysql -u root mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.28 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, 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>
执行用户密码更新sql
mysql> UPDATE user SET Password=PASSWORD('root') where USER='root';
Query OK, 4 rows affected (0.05 sec)
Rows matched: 4 Changed: 4 Warnings: 0
mysql>
查询更改的记录
mysql>select Host,User,Password,password_expired from user where user='root';
重要: 新设置用户或更改密码后需用flush privileges刷新MySQL的系统权限相关表,否则会出现拒绝访问,还有一种方法,就是重新启动mysql服务器,来使新设置生效。
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
退出mysql -- 重新登录
mysql> quit
Bye
登录mysql
执行show database;查看mysql数据库
这里报错:
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
提示在执行之前必须设置PASSWORD
---执行设置密码操作
mysql> SET PASSWORD = PASSWORD('123456');
Query OK, 0 rows affected (0.00 sec)
创建我们的mysql 库 bigdata;
使用测试数据库
创建表:
查询刚刚插入的数据
-=============下面是官网提供的文档================
2.5.5 Installing MySQL on Linux Using RPM Packages
Note
To install or upgrade to MySQL 5.6.11 or later, be sure to read the special instructions at the end of this section.
glibc
- From the MySQL software repositories, for the following platforms:
- For EL5, EL6, or EL7-based platforms and Fedora 22 or 23, use the MySQL Yum repository (see Section 2.5.1, “Installing MySQL on Linux Using the MySQL Yum Repository” for details).
- For SUSE Enterprise Linux Server, use the MySQL SLES repository (see Section 2.5.4, “Installing MySQL on Linux Using the MySQL SLES Repository”for details).
- From the MySQL Downloads page in the MySQL Developer Zone, which provides RPM packages that work for different platforms.
The discussion in this section applies only to the RPM packages downloaded from the MySQL Developer Zone.
Table 2.6 MySQL Installation Layout for Linux RPM Packages from the MySQL Developer Zone
Directory | Contents of Directory |
| Client programs and scripts |
| The mysqld server |
| Log files, databases |
| MySQL manual in Info format |
| Unix manual pages |
| Include (header) files |
| Libraries |
| Miscellaneous support files, including error messages, character set files, sample configuration files, SQL for database installation |
| Benchmarks |
Note
RPM distributions of MySQL are also provided by other vendors. Be aware that they may differ from those built by Oracle in features, capabilities, and conventions (including communication setup), and that the instructions in this manual do not necessarily apply to installing them. The vendor's instructions should be consulted instead. Because of these differences, RPM packages built by Oracle check whether such RPMs built by other vendors are installed. If so, the RPM does not install and produces a message explaining this.
rpm -i may result in messages that files in the RPM to be installed conflict with files from an installed package (denoted mysql-libs
MySQL-shared-compat
package that is meant to replace mysql-libs
and provides a replacement-compatible client library for older MySQL series. MySQL-shared-compat
is set up to make mysql-libs
obsolete, but rpm explicitly refuses to replace obsoleted packages when invoked with -i
(unlike -U
), which is why installation with rpm -iMySQL-shared-compat
can safely be installed alongside mysql-libs
because libraries are installed to different locations. Therefore, it is possible to install MySQL-shared-compat
first, then manually remove mysql-libs
before continuing with the installation. After mysql-libs
is removed, the dynamic linker stops looking for the client library in the location where mysql-libs
puts it, and the library provided by the MySQL-shared-compat
yum. In a directory containing all RPM packages for a MySQL release, yum install MySQL*rpm installs them in the correct order and removes mysql-libs
MySQL-server and MySQL-client As of MySQL 5.6.8, new RPM install operations (not upgrades) invoke mysql_install_db with the --random-passwords option that provides for more secure MySQL installation. Invoking mysql_install_db with --random-passwords causes it to assign a random password to the MySQL root accounts, set the “password expired” flag for those accounts, and not create anonymous-user MySQL accounts. It will be necessary after installation to start the server, connect as root using the initial random password, and assign a new root password. Until this is done, root cannot do anything else. This must be done for each root account you intend to use. To change the password, you can use the SET PASSWORD statement (for example, with the mysql client). You can also use mysqladmin or mysql_secure_installation. For additional details, see Section 4.4.3, “mysql_install_db. (Install operations using RPMs for Unbreakable Linux Network are unaffected because they do not use mysql_install_db.)
Important
RPMs for MySQL Cluster. Standard MySQL server RPMs built by MySQL do not provide support for the NDBCLUSTER storage engine. For more information about installing MySQL Cluster from RPMs, see Section 18.2, “MySQL Cluster Installation”.all installed RPMs, including the Server and Client
For upgrades, if your installation was originally produced by installing multiple RPM packages, it is best to upgrade all the installed packages, not just some. For example, if you previously installed the server and client RPMs, do not upgrade just the server RPM.
If the data directory exists at RPM installation time, the installation process does not modify existing data. This has the effect, for example, that accounts in the grant tables are not initialized to the default set of accounts.
error: removing these packages would break dependencies: libmysqlclient.so.10 is needed by ...
), you should also install the MySQL-shared-compat
.linux_glibc2.5.i386.rpm
, but particular packages can have different suffixes, described later. If you plan to install multiple RPM packages, you may wish to download the RPM Bundle tar MySQL-server-VERSION.linux_glibc2.5.i386.rpm
- The MySQL server. You need this unless you only want to connect to a MySQL server running on another machine.
MySQL-client-VERSION.linux_glibc2.5.i386.rpm
- The standard MySQL client programs. You probably always want to install this package.
MySQL-devel-VERSION.linux_glibc2.5.i386.rpm
- The libraries and include files needed to compile other MySQL clients, such as the Perl MySQL module. Install this RPM if you intend to compile C API applications.
MySQL-shared-VERSION.linux_glibc2.5.i386.rpm
libmysqlclient.so*
- ) that certain languages and applications need to dynamically load and use MySQL. It contains single-threaded and thread-safe libraries. Install this RPM if you intend to compile or run C API applications that depend on the shared client library.
MySQL-shared-compat-VERSION.linux_glibc2.5.i386.rpm
- This package includes the shared libraries for older releases, but not the libraries for the current release. It contains single-threaded and thread-safe libraries. Install this package if you have applications installed that are dynamically linked against older versions of MySQL but you want to upgrade to the current version without breaking the library dependencies.
MySQL-shared-compat
- RPM package enables users of Red Hat-provided
mysql-*-5.1
- RPM packages to migrate to Oracle-provided
MySQL-*-5.5
- packages.
MySQL-shared-compat
- replaces the Red Hat
mysql-libs
- package by replacing
libmysqlclient.so
- files of the latter package, thus satisfying dependencies of other packages on
mysql-libs
- . This change affects only users of Red Hat (or Red Hat-compatible) RPM packages. Nothing is different for users of Oracle RPM packages.
MySQL-embedded-VERSION.linux_glibc2.5.i386.rpm
- The embedded MySQL server library.
MySQL-test-VERSION.linux_glibc2.5.i386.rpm
- This package includes the MySQL test suite.
MySQL-VERSION.src.rpm
- This contains the source code for all of the previous packages. It can also be used to rebuild the RPMs on other architectures (for example, SPARC).
VERSION
PLATFORM
CPU
PLATFORM
and CPU
values indicate the type of system for which the package is built. PLATFORM
indicates the platform and CPU
glibc
2.5. The PLATFORM
Table 2.7 MySQL Linux RPM Package Platforms
PLATFORM | Intended Use |
|
|
| Red Hat Enterprise Linux 5 |
| Enterprise Linux 6 or 7 |
| SUSE Linux Enterprise Server 11 or 12 |
linux_glibc2.5
CPU
Table 2.8 MySQL Linux RPM Package CPU Identifiers
CPU | Intended Processor Type or Family |
| Pentium processor or better, 32 bit |
| 64-bit x86 processor |
MySQL-server
rpm -qpl MySQL-server-VERSION.linux_glibc2.5.i386.rpm
VERSION
To perform a standard minimal installation, install the server and client RPMs:
rpm -i MySQL-server-VERSION.linux_glibc2.5.i386.rpm
VERSION
rpm -i MySQL-client-VERSION.linux_glibc2.5.i386.rpm
VERSION
To install only the client programs, install just the client RPM:
rpm -i MySQL-client-VERSION.linux_glibc2.5.i386.rpm
VERSION
RPM provides a feature to verify the integrity and authenticity of packages before installing them. To learn more about this feature, see Section 2.1.3, “Verifying Package Integrity Using MD5 Checksums or GnuPG”.
/var/lib/mysql directory. The RPM also creates a login account for a user named mysql (if one does not exist) to use for running the MySQL server, and creates the appropriate entries in /etc/init.d/ to start the server automatically at boot time. (This means that if you have performed a previous installation and have made changes to its startup script, you may want to make a copy of the script so that you can reinstall it after you install a newer RPM.) See Section 2.10.5, “Starting and Stopping MySQL Automatically”, for more information on how MySQL can be started automatically on system startup.
In MySQL 5.6, for a new installation using RPM packages, the server boot scripts are installed, but the MySQL server is not started at the end of the installation, since the status of the server during an unattended installation is not known.
In MySQL 5.6, for an upgrade installation using RPM packages, if the MySQL server is running when the upgrade occurs, the MySQL server is stopped, the upgrade occurs, and the MySQL server is restarted. If the MySQL server is not already running when the RPM upgrade occurs, the MySQL server is not started at the end of the installation.
Note
Upgrading from a community version to a commercial version of MySQL requires that you first uninstall the community version and then install the commercial version. In this case, you must restart the server manually after the upgrade.
If something goes wrong, you can find more information in the binary installation section. See Section 2.2, “Installing MySQL on Unix/Linux Using Generic Binaries”.
Note
The accounts created in the MySQL grant tables for an RPM installation initially have no passwords. After starting the server, you should assign passwords to them using the instructions in Section 2.10, “Postinstallation Setup and Testing”.
mysql
and a group named mysql
on the system using the useradd, groupadd, and usermod commands. Those commands require appropriate administrative privileges, which is required for locally managed users and groups (as listed in the /etc/passwd
and/etc/group
files) by the RPM installation process being run by root
.mysql
user, you may find that MySQL displays “Invalid (old?) table or database name” errors that mention .mysqlgui
, lost+found
,.mysqlgui
, .bash_history
, .fonts.cache-1
, .lesshst
, .mysql_history
, .profile
, .viminfo
, and similar files created by MySQL or operating system utilities. You can safely ignore these error messages or remove the files or directories that cause them if you do not need them.
For nonlocal user management (LDAP, NIS, and so forth), the administrative tools may require additional authentication (such as a password), and will fail if the installing user does not provide this authentication. Even if they fail, the RPM installation will not abort but succeed, and this is intentional. If they failed, some of the intended transfer of ownership may be missing, and it is recommended that the system administrator then manually ensures some appropriate user and group exists and manually transfers ownership following the actions in the RPM spec file.
In MySQL 5.6.11, the RPM spec file has been updated, which has the following consequences:
- yum.
- For upgrades, it is necessary to clean up any earlier MySQL installations. In effect, the update is performed by removing the old installations and installing the new one.
Additional details follow.
yum:
yum install MySQL-server-NEWVERSION.linux_glibc2.5.i386.rpm
NEWVERSION
For upgrades to MySQL 5.6.11 or later, perform the upgrade by removing the old installation and installing the new one:
X
- installation.
OLDVERSION
rpm -e MySQL-server-OLDVERSION.linux_glibc2.5.i386.rpm
OLDVERSION
Repeat this step for all installed MySQL RPMs.
NEWVERSION
rpm -ivh MySQL-server-NEWVERSION.linux_glibc2.5.i386.rpm
NEWVERSION
yum:
yum remove MySQL-server-OLDVERSION.linux_glibc2.5.i386.rpm
OLDVERSION
yum install MySQL-server-NEWVERSION.linux_glibc2.5.i386.rpm
NEWVERSION
PREV HOME UP NEXT
User Comments
Bahadir Malkoç on July 2, 2013
For Centos 6, RPM may complain that you may have mysql-libs that is of version 5.1 due to crontabs. You can do the following to solve this issue:
rpm -i MySQL-shared-compat-*
yum remove mysql-libs
rpm -i MySQL-server-*
rpm -i MySQL-client-*