使用Linux过程中的坑

下载安装MySQL:CentOS命令下载并获取初始密码

2019-03-09  本文已影响0人  违规昵称不予展示

1. 卸载CentOS自带的mariadb(为什么(⊙o⊙)?我也不知道)

yum remove mariadb-libs.x86_64

2. 然后用命令下载MySQL的源文件

先把目录定位到 tmp

cd /tmp

然后再下载(这里我下载的是mysql8,想要啥版本的可以自己去找https://repo.mysql.com/)

wget https://repo.mysql.com/mysql80-community-release-el7-1.noarch.rpm

至于下载的版本可以去这里看看
https://repo.mysql.com/
记得CentOS就要下载版本是是elXX的而不是sles(SUSE)等的

3. 用yum本地安装(你可以用ll命令来看看你下的文件名叫啥)

yum localinstall mysql80-community-release-sles12-1.noarch.rpm 

4. 安装数据库服务

yum install mysql-community-server

我有一次下错包了上面这个命令没有,但下面这个命令有用,很奇怪

yum install mysql-server

5. 启动你的服务吧

service mysqld start

6. 获取你的初始密码

cat /var/log/mysqld.log | grep 'password'

2019/3/14/14.01

后来使用虚拟环境安装mysqlclient的时候报了一个错误

  File "/root/.local/lib/python3.7/site-packages/pipenv/core.py", line 1992, in do_install
      skip_lock=skip_lock,
  File "/root/.local/lib/python3.7/site-packages/pipenv/core.py", line 1253, in do_init
      pypi_mirror=pypi_mirror,
  File "/root/.local/lib/python3.7/site-packages/pipenv/core.py", line 859, in do_install_dependencies
      retry_list, procs, failed_deps_queue, requirements_dir, **install_kwargs
  File "/root/.local/lib/python3.7/site-packages/pipenv/core.py", line 763, in batch_install
      _cleanup_procs(procs, not blocking, failed_deps_queue, retry=retry)
  File "/root/.local/lib/python3.7/site-packages/pipenv/core.py", line 681, in _cleanup_procs
      raise exceptions.InstallError(c.dep.name, extra=err_lines)
['Collecting mysqlclient==1.4.2.post1 
(from -r /tmp/pipenv-8n2dv523-requirements/pipenv-pqd4r5xc-requirement.txt (line 1))', 
'  Using cached https://files.pythonhosted.org/packages/f4/f1/
3bb6f64ca7a429729413e6556b7ba5976df06019a5245a43d36032f1061e/
mysqlclient-1.4.2.post1.tar.gz',
 '    Complete output from command python setup.py egg_info:',
  '    /bin/sh: mysql_config: command not found',
   '    Traceback (most recent call last):', 
   '      File "<string>", line 1, in <module>', 
   '      File "/tmp/pip-install-1r3548oo/mysqlclient/setup.py", line 16, in <module>', 
   '        metadata, options = get_config()', 
   '      File "/tmp/pip-install-1r3548oo/mysqlclient/setup_posix.py", line 51, in get_config', 
   '        libs = mysql_config("libs")', 
   '      File "/tmp/pip-install-1r3548oo/mysqlclient/setup_posix.py", line 29, in mysql_config', 
   '        raise EnvironmentError("%s not found" % (_mysql_config_path,))', 
   '    OSError: mysql_config not found', '    ', 
   '    ----------------------------------------']
['Command "python setup.py egg_info" failed with error code 1 in 
/tmp/pip-install-1r3548oo/mysqlclient/']

为了好分析,形式已经被我改了一下
有一句OSError: mysql_config not found为啥呢,查了一下,是缺少了一些依赖
真难受,windows下就没有这些依赖问题(*  ̄︿ ̄)
下载依赖

yum install mysql-devel gcc gcc-devel python-devel
上一篇下一篇

猜你喜欢

热点阅读