linux上安装mysql
2015-12-17 09:03
591 查看
安装mysql:
1。从bin文件安装。mysql-5.7.10-linux-glibc2.5-x86_64.tar2。安装的指导文件:解压缩包的BINARY_INSTALL文件中可以找到。步骤大概是这样的,总结一下遇到的坑:
shell>groupaddmysql
shell>useradd-r-gmysql-s/bin/falsemysql
shell>cd/usr/local#取决于安装文件放的位置
shell>tarzxvf/path/to/mysql-VERSION-OS.tar.gz#这是在解压缩
shell>ln-sfull-path-to-mysql-VERSION-OSmysql
shell>cdmysql
shell>mkdirmysql-files
shell>chmod770mysql-files
shell>chown-Rmysql.
shell>chgrp-Rmysql.
#这是在不同版本之间的选择。安装过程中会帮你生成一个初始密码,记下来后边连接的时候用
shell>bin/mysql_install_db--user=mysql#BeforeMySQL5.7.6
shell>bin/mysqld--initialize--user=mysql#MySQL5.7.6andup
shell>bin/mysql_ssl_rsa_setup#MySQL5.7.6andup
shell>chown-Rroot.
shell>chown-Rmysqldatamysql-files
shell>bin/mysqld_safe--user=mysql&
3。启动的时候有两个问题
A。启动的时候会将安装log写到/var/log/mysqld.log目录下,将PID写在/var/run/mysqld/mysqld.pid里面,但是发现执行之前并没有创建这些文件甚至目录。故需要你手动创建需要的目录或者文件,。
B。因为是用的用户名myuser。故而上面创建的文件需要你给mysql用户加一个权限
root密码保存在:/root/.mysql_secret
4。安装完成,需要连接。这个时候因为密码是过期的所以连接失败。为了让这个密码临时能用:
vim/etc/my.cnf.在这个文件中追加:skip-grant-tables
重启mysql服务
5。查询现有数据库的schema
执行/opt/app/mysql/bin/mysql将进入>mysql的指令。可以发送select等语句了。但是为了可视化。最好选择一些mysql的workbench
如果4.5不管用只能改密码了。
方法:
1。mysql-hlocalhost-uroot-phttp://stackoverflow.com/questions/1559955/host-xxx-xx-xxx-xxx-is-not-allowed-to-connect-to-this-mysql-server 重启服务就Ok了
安装phpMyadmin来管理数据库:
如果访问phpMyAdmin服务的时候出现Forbidden。可能的原因如下:
1。没有安装php:$yuminstallphp
2.默认的只能允许本地访问,如果想远程修改这个配置文件vim/etc/httpd/conf/httpd.conf
3。还有可能是
#vim/etc/httpd/conf/httpd.conf
Addthefollowinglineshere:
<Directory"/usr/share/phpmyadmin"> Orderallow,deny Allowfromall </Directory> 最后还是不行
Firsteditthefile/etc/httpd/conf.d/phpMyAdmin.confandaddtheadditionallinetothedirectorysettings:
<Directory/usr/share/phpMyAdmin/> orderdeny,allow denyfromall allowfrom127.0.0.1 allowfrom192.168.1.0/15 </Directory>
Ifyouwantedtoallowaccesstoeverybodythenyoucouldjustchangeitto:
<Directory/usr/share/phpMyAdmin/> orderallow,deny allowfromall </Directory> 解决了上一部的Forbiden错误进入登陆界面:#1862CannotlogintotheMySQLserver 如果有上面的错误,证明数据库密码过期,需要重置。参照安装数据库的最后一步
新用户名远程连接:
至此其实可以用PHPMyadmin来管理你的数据库了,包括查询等,但是可以装一个下面的客户端,远程连接上去。更好
本地安装mysqlworkbench
1.下载mysqlworkbench:2.下在完成以后shell到这个rpm的路径。执行:sudorpminstallmysqlworkbench.rpm在安装过程中发现错误
获取GPG密钥失败:[Errno14]curl#37-"Couldn'topenfile/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6"
解决办法,从rpm上下载这个缺失的文件
rpm--import
还有可能出现一些依赖的lib版本不正确的情况,如
错误:软件包:mysql-workbench-community-6.3.6-1.el7.x86_64(/mysql-workbench-community-6.3.6-1.el7.x86_64)
需要:python-paramiko>=1.15.1
已安装:python-paramiko-1.12.4-1.el7.centos.noarch(@extras)
python-paramiko=1.12.4-1.el7.centos
解决办法:当前的centos中存在着依赖,他的版本低于需要的。
yumremovepython-paramiko-1.12.4-1.el7.centos.noarch
网上下载正确的rpm本地安装一下就行了
启动mysqlworkbench的时候出现错误
[ygshen@localhostSoftware]$mysql-workbench
/usr/libexec/mysql-workbench/mysql-workbench-bin:errorwhileloadingsharedlibraries:libtinyxml.so.0:cannotopensharedobjectfile:Nosuchfileordirectory
原因是缺少依赖包,按理说在rpminstall的过程中应该安装了但是没有需要手动撞一下
sudoyuminstalllibtiny(tab以下)会发现所有的版本
[ygshen@localhostmysql-workbench]$sudoyuminstalltiny
tinyca2.noarchtinyxml2-devel.i686tinyxml-devel.i686
tinyfugue.x86_64tinyxml2-devel.x86_64tinyxml-devel.x86_64
tinymce.noarchtinyxml2.i686tinyxml.i686
tinyproxy.x86_64tinyxml2.x86_64
安装以下就可以了
至此安装完成,启动>shell:mysql-workbench就启动gui了
相关文章推荐
- GPIO的驱动模型——linux
- linux 常用命令解压压缩
- centos6.5下安装mysql
- Linux ls 自定义时间显示格式
- linux sort,uniq,cut,wc命令详解
- centos 6搭建tftp服务器
- Linux netstat命令详解
- Linux netstat命令详解
- linux svn conflict
- linux练习题第二章
- Centos7 编译安装python3
- Linux内核结构 笔记
- 进程栈与线程栈
- Linux 初始化 init 系统,第 3 部分: Systemd
- Linux 初始化 init 系统,第 2 部分: UpStart
- CentOS下PHP7的编译安装及MySQL的支持和一些常见问题的解决办法
- linux find命令技巧
- 十大好用的Linux实用工具推荐
- Linux 定时任务
- Linux 初始化 init 系统,第 1 部分: sysvinit