码迷,mamicode.com
首页 > 数据库 > 详细

mysql linux安装yum

时间:2016-06-30 23:34:44      阅读:404      评论:0      收藏:0      [点我收藏+]

标签:yum   mysql   

1     配置yum

[root@daidai media]# cd Server/

[root@daidai Server]# pwd

/media/Server

[root@daidai Server]# vi/etc/yum.repos.d/rhel-debuginfo.repo

[rhel-debuginfo]

name=Red Hat Enterprise Linux $releasever -$basearch - Debug

baseurl=ftp://ftp.redhat.com/pub/redhat/linux/enterprise/$releasever/en/os/$basearch/Debuginfo/

enabled=0

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

 

[rhel-debuginfo-beta]

name=Red Hat Enterprise Linux $releaseverBeta - $basearch - Debug

baseurl=ftp://ftp.redhat.com/pub/redhat/linux/beta/$releasever/en/os/$basearch/Debuginfo/

enabled=0

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta,file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

 

[rhel-5.5]

name=rhel5.5

baseurl=file:///media/Server

enabled=1

gpgcheck=0

2     检查是否安装myslq

[root@daidai Server]# yum list installed mysql*

Loaded plugins: rhnplugin, security

This system is not registered with RHN.

RHN support will be disabled.

Error: No matching Packages to list

3     查看yum源中的mysql版本

[root@daidai Server]# yum list|grep mysql

This system is not registered with RHN.

RHN support will be disabled.

apr-util-mysql.x86_64                       1.2.7-11.el5               rhel-5.5

freeradius-mysql.x86_64                     1.1.3-1.6.el5              rhel-5.5

freeradius2-mysql.x86_64                    2.1.7-7.el5                rhel-5.5

libdbi-dbd-mysql.x86_64                     0.8.1a-1.2.2               rhel-5.5

mod_auth_mysql.x86_64                       1:3.0.0-3.2.el5_3          rhel-5.5

mysql.i386                                 5.0.77-4.el5_4.2          rhel-5.5

mysql.x86_64                               5.0.77-4.el5_4.2          rhel-5.5

mysql-bench.x86_64                          5.0.77-4.el5_4.2           rhel-5.5

mysql-connector-odbc.x86_64                 3.51.26r1127-1.el5         rhel-5.5

mysql-devel.i386                           5.0.77-4.el5_4.2          rhel-5.5

mysql-devel.x86_64                          5.0.77-4.el5_4.2           rhel-5.5

mysql-server.x86_64                         5.0.77-4.el5_4.2           rhel-5.5

mysql-test.x86_64                           5.0.77-4.el5_4.2           rhel-5.5

php-mysql.x86_64                            5.1.6-27.el5               rhel-5.5

qt4-mysql.x86_64                            4.2.1-1                    rhel-5.5

rsyslog-mysql.x86_64                        3.22.1-3.el5               rhel-5.5

[root@daidai Server]# yum list installed|grep mysql

This system is not registered with RHN.

RHN support will be disabled.

4     安装mysql

[root@daidai Server]# yum install mysql -y

Loaded plugins: rhnplugin, security

This system is not registered with RHN.

RHN support will be disabled.

Setting up Install Process

Resolving Dependencies

--> Running transaction check

---> Package mysql.i3860:5.0.77-4.el5_4.2 set to be updated

--> Processing Dependency: perl(DBI) forpackage: mysql

---> Package mysql.x86_640:5.0.77-4.el5_4.2 set to be updated

--> Running transaction check

---> Package perl-DBI.x86_640:1.52-2.el5 set to be updated

--> Finished Dependency Resolution

 

Dependencies Resolved

 

=======================================================================================================================================================================

 Package                               Arch                                Version                                         Repository                             Size

=======================================================================================================================================================================

Installing:

 mysql                                 i386                               5.0.77-4.el5_4.2                               rhel-5.5                             4.8 M

 mysql                                 x86_64                              5.0.77-4.el5_4.2                                rhel-5.5                              4.8 M

Installing for dependencies:

 perl-DBI                              x86_64                              1.52-2.el5                                     rhel-5.5                              605 k

 

Transaction Summary

=======================================================================================================================================================================

Install       3 Package(s)

Upgrade       0 Package(s)

 

Total download size: 10 M

Downloading Packages:

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------

Total                                                                                                                                  1.2GB/s |  10 MB     00:00    

Running rpm_check_debug

Running Transaction Test

Finished Transaction Test

Transaction Test Succeeded

Running Transaction

 Installing     : perl-DBI                                                                                                                                       1/3

 Installing     : mysql                                                                                                                                          2/3

 Installing     : mysql                                                                                                                                          3/3

 

Installed:

 mysql.i386 0:5.0.77-4.el5_4.2                                                    mysql.x86_64 0:5.0.77-4.el5_4.2                                                   

 

Dependency Installed:

 perl-DBI.x86_64 0:1.52-2.el5                                                                                                                                        

 

Complete!

4.1   安装mysql-server

[root@daidai Server]# yum install mysql-server -y

Loaded plugins: rhnplugin, security

This system is not registered with RHN.

RHN support will be disabled.

Setting up Install Process

Resolving Dependencies

--> Running transaction check

---> Package mysql-server.x86_640:5.0.77-4.el5_4.2 set to be updated

--> Processing Dependency: perl-DBD-MySQLfor package: mysql-server

--> Running transaction check

---> Package perl-DBD-MySQL.x86_640:3.0007-2.el5 set to be updated

--> Finished Dependency Resolution

 

Dependencies Resolved

 

=======================================================================================================================================================================

 Package                                    Arch                               Version                                     Repository                            Size

=======================================================================================================================================================================

Installing:

 mysql-server                               x86_64                             5.0.77-4.el5_4.2                             rhel-5.5                             9.8 M

Installing for dependencies:

 perl-DBD-MySQL                             x86_64                             3.0007-2.el5                                 rhel-5.5                             147 k

 

Transaction Summary

=======================================================================================================================================================================

Install       2 Package(s)

Upgrade       0 Package(s)

 

Total download size: 10 M

Downloading Packages:

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------

Total                                                                                                                                 3.9 GB/s |  10 MB     00:00    

Running rpm_check_debug

Running Transaction Test

Finished Transaction Test

Transaction Test Succeeded

Running Transaction

 Installing     :perl-DBD-MySQL                                                                                                                                 1/2

 Installing     : mysql-server                                                                                                                                    2/2

 

Installed:

 mysql-server.x86_64 0:5.0.77-4.el5_4.2                                                                                                                              

 

Dependency Installed:

 perl-DBD-MySQL.x86_64 0:3.0007-2.el5                                                                                                                                

 

Complete!

4.2   安装mysql-devel

[root@daidai Server]# yum install mysql-devel -y

Loaded plugins: rhnplugin, security

This system is not registered with RHN.

RHN support will be disabled.

Setting up Install Process

Resolving Dependencies

--> Running transaction check

---> Package mysql-devel.i3860:5.0.77-4.el5_4.2 set to be updated

---> Package mysql-devel.x86_640:5.0.77-4.el5_4.2 set to be updated

--> Finished Dependency Resolution

 

Dependencies Resolved

 

=======================================================================================================================================================================

 Package                                 Arch                               Version                                         Repository                            Size

=======================================================================================================================================================================

Installing:

 mysql-devel                             i386                              5.0.77-4.el5_4.2                               rhel-5.5                            2.4 M

 mysql-devel                             x86_64                             5.0.77-4.el5_4.2                                rhel-5.5                             2.5 M

 

Transaction Summary

=======================================================================================================================================================================

Install       2 Package(s)

Upgrade       0 Package(s)

 

Total download size: 4.9 M

Downloading Packages:

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------

Total                                                                                                                                 1.4 GB/s | 4.9 MB     00:00    

Running rpm_check_debug

Running Transaction Test

Finished Transaction Test

Transaction Test Succeeded

Running Transaction

 Installing     : mysql-devel                                                                                                                                    1/2

 Installing     : mysql-devel                                                                                                                                    2/2

 

Installed:

 mysql-devel.i386 0:5.0.77-4.el5_4.2                                              mysql-devel.x86_64 0:5.0.77-4.el5_4.2                                             

 

Complete!

5     修改默认字符集

[root@daidai Server]# vi /etc/my.cnf

[mysqld]

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

user=mysql

# Default to using old password format forcompatibility with mysql 3.x

# clients (those using the mysqlclient10compatibility package).

old_passwords=1

default-character-set=utf8

 

# Disabling symbolic-links is recommendedto prevent assorted security risks;

# to do so, uncomment this line:

# symbolic-links=0

 

[mysqld_safe]

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

6     启停mysql

[root@daidai Server]# service mysqld start

[root@daidai Server]# service mysqld stop

7     修改mysql root密码

[root@daidai Server]# mysqladmin -u root password love8013

7.1   登录mysql

[root@daidai Server]# mysql -u root@localhost

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 4

Server version: 5.0.77 Source distribution

 

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ toclear the buffer.

 

mysql>

7.2   创建db

mysql> showdatabases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| test               |

+--------------------+

2 rows in set (0.00 sec)

mysql> createdatabase ocp;

ERROR 1044 (42000): Access denied for user‘‘@‘localhost‘ to database ‘ocp‘

窗口1

[root@daidai Server]# service mysqld stop

Stopping MySQL:                                           [  OK  ]

[root@daidai Server]# mysqld_safe --skip-grant-table

Starting mysqld daemon with databases from/var/lib/mysql

窗口2

[root@daidai ~]# mysql -u root mysql

Reading table information for completion oftable and column names

You can turn off this feature to get aquicker startup with -A

 

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.0.77 Source distribution

 

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ toclear the buffer.

 

mysql> delete from user where user=‘‘;

Query OK, 2 rows affected (0.00 sec)

 

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

 

mysql> \q

Bye

[root@daidai ~]# mysql -u root -p  love8013

Enter password:

ERROR 1049 (42000): Unknown database‘love8013‘

[root@daidai ~]# mysql -u root -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 3

Server version: 5.0.77 Source distribution

 

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ toclear the buffer.

 

mysql> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| test               |

+--------------------+

3 rows in set (0.00 sec)

 

mysql> create database ocp;

Query OK, 1 row affected (0.00 sec)

 

mysql> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| ocp                |

| test               |

+--------------------+

4 rows in set (0.00 sec)


本文出自 “90SirDB” 博客,请务必保留此出处http://90sirdb.blog.51cto.com/8713279/1794720

mysql linux安装yum

标签:yum   mysql   

原文地址:http://90sirdb.blog.51cto.com/8713279/1794720

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!