542179528 发表于 2018-5-20 10:28:20

mysql linux安装yum

1   配置yum
  # cd Server/
  # pwd
  /media/Server
  # vi/etc/yum.repos.d/rhel-debuginfo.repo
  
  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
  
  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
  
  name=rhel5.5
  baseurl=file:///media/Server
  enabled=1
  gpgcheck=0
2   检查是否安装myslq
  # 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版本
  # 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
  # yum list installed|grep mysql
  This system is not registered with RHN.
  RHN support will be disabled.
4   安装mysql
  # 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
  # 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
  # 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   修改默认字符集
  # vi /etc/my.cnf
  
  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
  
  log-error=/var/log/mysqld.log
  pid-file=/var/run/mysqld/mysqld.pid
6   启停mysql
  # service mysqld start
  # service mysqld stop
7   修改mysql root密码
  # mysqladmin -u root password love8013
7.1   登录mysql
  # 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:
  # service mysqld stop
  Stopping MySQL:                                          
  # mysqld_safe --skip-grant-table
  Starting mysqld daemon with databases from/var/lib/mysql
  窗口2:
  # 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
  # mysql -u root -plove8013
  Enter password:
  ERROR 1049 (42000): Unknown database'love8013'
  # 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)
  
页: [1]
查看完整版本: mysql linux安装yum