设为首页 收藏本站
查看: 616|回复: 0

[经验分享] mysql linux安装yum

[复制链接]

尚未签到

发表于 2018-5-20 10:28:20 | 显示全部楼层 |阅读模式
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)
  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-462894-1-1.html 上篇帖子: Linux文本工具sed 下篇帖子: Linux第二周
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表