当前位置:   article > 正文

非root权限安装mysql_非root用户安装mysql

非root用户安装mysql

所需软件:

  • mysql的安装包
  • cmake的安装包

因为我用的linux平台已经事先安装好了cmake,所以我在网上找了一份安装教程,安装包可以到我的百度网盘里提取。链接:https://pan.baidu.com/s/1bs9y0zhXkRaYhXRSXg_FpA 密码:sy4z

cmake安装:

  1.   ./configure --prefix=$HOME/local/cmake-2.8.12.2
  2.   make
  3.   make install

至此,cmake就ok了,你可以在 $HOME/local/cmake-2.8.12.2/bin 目录里面看到cmake了。为了不用每次都输入这么长串的地址才能访问cmake,当然有必要把$HOME/local/cmake-2.8.12.2/bin放到环境变量里面了。

  1. vi ~/.bash_profile
  2. 在 path的后面加上 $HOME/local/cmake-2.8.12.2/bin
  3. source ~/.bash_profile

如此一来,就可以和cmake亲密接触了。不信,你在任意路径输入 cmake –version看看。


mysql安装包

   mysql-5.6.40,网盘链接,链接:https://pan.baidu.com/s/1skeO_Egp6c9NJlDPUw1GeQ 密码:3m1k 

mysql安装:

    我是设置~/local/  作为mysql的安装目录, mysql包下载至~/software/ 目录下

    1、解压安装包

tar  -zxvf  mysql-5.6.40

    2、因为安装不需要root,所以我们需要在我们自己目录下配置一些文件或者文件夹来存放数据以及日志

  1. mkdir ~/local/mysql #安装目录
  2. cd ~/local/mysql
  3. mdkir data #数据存放
  4. touch mysql_3307.sock
  5. mdkir tmp
  6. mkdir -p log #日志有关文件夹
  7. cd log
  8. touch mysql.err #报错信息
  9. touch mysql.log #日志信息

    3、进行cmake编译

  1. $cd mysql-5.6.40
  2. $cmake . -DCMAKE_INSTALL_PREFIX=~/local/mysql -DMYSQL_UNIX_ADDR=~/local/mysql/mysql_3307.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=~/local/mysql/data -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3307
  3. ----------漫长的等待----------
  4. $make
  5. ----------漫长的等待----------
  6. $make install
  7. ----------漫长的等待----------

  4、配置mysql

  1. $cd ~/local/mysql
  2. $cp support-files/my-default.cnf ./my.cnf
  3. $vi my.cnf #示例
  4. [client]
  5. port = 3307 #端口可以改
  6. socket = /amoydx/USER/huangkefei/software/mysql/mysql_3307.sock
  7. # Remove leading # and set to the amount of RAM for the most important data
  8. # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
  9. # innodb_buffer_pool_size = 128M
  10. # Remove leading # to turn on a very important data integrity option: logging
  11. # changes to the binary log between backups.
  12. # log_bin
  13. [mysqld]
  14. # These are commonly set, remove the # and set as required.
  15. basedir = /amoydx/USER/huangkefei/software/mysql
  16. datadir = /amoydx/USER/huangkefei/software/mysql/data
  17. port = 3307 #端口可以改
  18. socket = /amoydx/USER/huangkefei/software/mysql/mysql_3307.sock
  19. tmpdir = /amoydx/USER/huangkefei/software/mysql/tmp
  20. log-error = /amoydx/USER/huangkefei/software/mysql/log/mysql.err
  21. general_log_file = /amoydx/USER/huangkefei/software/mysql/log/mysql.log
  22. general_log = 1
  23. # server_id = .....

  5、安装mysql

  1. #在mysql目录下
  2. ./scripts/mysql_install_db --basedir=~/local/mysql --datadir=~/local/mysql/data --user=huangkefei --defaults-file=~/local/mysql/my.cnf --socket=~/local/mysql/mysql_3307.sock

   6、启动mysql

nohup ./bin/mysqld_safe  --defaults-file=~/local/mysql/my.cnf &

  

在这个地方,我出现了报错: Table 'mysql.plugin' doesn't exist

    解决方案:

  1. $ ./scripts/mysql_install_db --basedir=~/local/mysql --datadir=~/local/mysql/data
  2. #输出记录如下
  3. '''
  4. Installing MySQL system tables...2018-05-29 09:28:24 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
  5. 2018-05-29 09:28:24 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
  6. 2018-05-29 09:28:24 0 [Note] /amoydx/USER/huangkefei/software/mysql/bin/mysqld (mysqld 5.6.40) starting as process 963 ...
  7. 2018-05-29 09:28:24 963 [Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 5000)
  8. 2018-05-29 09:28:24 963 [Warning] Buffered warning: Changed limits: table_open_cache: 431 (requested 2000)
  9. 2018-05-29 09:28:24 963 [Note] InnoDB: Using atomics to ref count buffer pool pages
  10. 2018-05-29 09:28:24 963 [Note] InnoDB: The InnoDB memory heap is disabled
  11. 2018-05-29 09:28:24 963 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
  12. 2018-05-29 09:28:24 963 [Note] InnoDB: Memory barrier is not used
  13. 2018-05-29 09:28:24 963 [Note] InnoDB: Compressed tables use zlib 1.2.3
  14. 2018-05-29 09:28:24 963 [Note] InnoDB: Not using CPU crc32 instructions
  15. 2018-05-29 09:28:24 963 [Note] InnoDB: Initializing buffer pool, size = 128.0M
  16. 2018-05-29 09:28:24 963 [Note] InnoDB: Completed initialization of buffer pool
  17. 2018-05-29 09:28:24 963 [Note] InnoDB: Highest supported file format is Barracuda.
  18. 2018-05-29 09:28:24 963 [Note] InnoDB: 128 rollback segment(s) are active.
  19. 2018-05-29 09:28:24 963 [Note] InnoDB: Waiting for purge to start
  20. 2018-05-29 09:28:24 963 [Note] InnoDB: 5.6.40 started; log sequence number 1600617
  21. 2018-05-29 09:28:24 963 [Note] Binlog end
  22. 2018-05-29 09:28:24 963 [Note] InnoDB: FTS optimize thread exiting.
  23. 2018-05-29 09:28:24 963 [Note] InnoDB: Starting shutdown...
  24. 2018-05-29 09:28:26 963 [Note] InnoDB: Shutdown completed; log sequence number 1625997
  25. OK
  26. Filling help tables...2018-05-29 09:28:26 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
  27. 2018-05-29 09:28:26 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
  28. 2018-05-29 09:28:26 0 [Note] /amoydx/USER/huangkefei/software/mysql/bin/mysqld (mysqld 5.6.40) starting as process 1105 ...
  29. 2018-05-29 09:28:26 1105 [Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 5000)
  30. 2018-05-29 09:28:26 1105 [Warning] Buffered warning: Changed limits: table_open_cache: 431 (requested 2000)
  31. 2018-05-29 09:28:26 1105 [Note] InnoDB: Using atomics to ref count buffer pool pages
  32. 2018-05-29 09:28:26 1105 [Note] InnoDB: The InnoDB memory heap is disabled
  33. 2018-05-29 09:28:26 1105 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
  34. 2018-05-29 09:28:26 1105 [Note] InnoDB: Memory barrier is not used
  35. 2018-05-29 09:28:26 1105 [Note] InnoDB: Compressed tables use zlib 1.2.3
  36. 2018-05-29 09:28:26 1105 [Note] InnoDB: Not using CPU crc32 instructions
  37. 2018-05-29 09:28:26 1105 [Note] InnoDB: Initializing buffer pool, size = 128.0M
  38. 2018-05-29 09:28:26 1105 [Note] InnoDB: Completed initialization of buffer pool
  39. 2018-05-29 09:28:26 1105 [Note] InnoDB: Highest supported file format is Barracuda.
  40. 2018-05-29 09:28:26 1105 [Note] InnoDB: 128 rollback segment(s) are active.
  41. 2018-05-29 09:28:26 1105 [Note] InnoDB: Waiting for purge to start
  42. 2018-05-29 09:28:26 1105 [Note] InnoDB: 5.6.40 started; log sequence number 1625997
  43. 2018-05-29 09:28:26 1105 [Note] Binlog end
  44. 2018-05-29 09:28:26 1105 [Note] InnoDB: FTS optimize thread exiting.
  45. 2018-05-29 09:28:26 1105 [Note] InnoDB: Starting shutdown...
  46. 2018-05-29 09:28:27 1105 [Note] InnoDB: Shutdown completed; log sequence number 1626007
  47. OK
  48. To start mysqld at boot time you have to copy
  49. support-files/mysql.server to the right place for your system
  50. PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
  51. To do so, start the server, then issue the following commands:
  52. /amoydx/USER/huangkefei/software/mysql/bin/mysqladmin -u root password 'new-password'
  53. /amoydx/USER/huangkefei/software/mysql/bin/mysqladmin -u root -h login-1-1.local password 'new-password'
  54. Alternatively you can run:
  55. /amoydx/USER/huangkefei/software/mysql/bin/mysql_secure_installation
  56. which will also give you the option of removing the test
  57. databases and anonymous user created by default. This is
  58. strongly recommended for production servers.
  59. See the manual for more instructions.
  60. You can start the MySQL daemon with:
  61. cd . ; /amoydx/USER/huangkefei/software/mysql/bin/mysqld_safe &
  62. You can test the MySQL daemon with mysql-test-run.pl
  63. cd mysql-test ; perl mysql-test-run.pl
  64. Please report any problems at http://bugs.mysql.com/
  65. The latest information about MySQL is available on the web at
  66. http://www.mysql.com
  67. Support MySQL by buying support/licenses at http://shop.mysql.com
  68. WARNING: Found existing config file /amoydx/USER/huangkefei/software/mysql/my.cnf on the system.
  69. Because this file might be in use, it was not replaced,
  70. but was used in bootstrap (unless you used --defaults-file)
  71. and when you later start the server.
  72. The new default config file was created as /amoydx/USER/huangkefei/software/mysql/my-new.cnf,
  73. please compare it with your file and take the changes you need.
  74. WARNING: Default config file /etc/my.cnf exists on the system
  75. This file will be read by default by the MySQL server
  76. If you do not want to use this, either remove it, or use the
  77. --defaults-file argument to mysqld_safe when starting the server
  78. '''
  79. 再重新启动mysql,就OK了。

   7、查看mysql是否在运行

  1. $ ps
  2. PID TTY TIME CMD
  3. 5927 pts/3 00:00:00 mysqld_safe
  4. 6107 pts/3 00:00:00 mysqld
  5. 6378 pts/3 00:00:00 ps
  6. 27268 pts/3 00:00:00 bash

  

基本配置:

1、修改root密码

$./bin/mysqladmin --socket=~/local/mysql/mysql_3307.sock -uroot password 123456

2、本机登录mysql

$./bin/mysql --socket=~/local/mysql/mysql_3307.sock -uroot password 123456

3、创建用户(授权)

  1. $./bin/mysql -u root -p
  2. Enter password: ******
  3. ./bin/mysql: Unknown OS character set 'ISO-8859-15'.
  4. ./bin/mysql: Switching to the default character set 'utf8'.
  5. Welcome to the MySQL monitor. Commands end with ; or \g.
  6. Your MySQL connection id is 3
  7. Server version: 5.6.40-log Source distribution
  8. Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
  9. Oracle is a registered trademark of Oracle Corporation and/or its
  10. affiliates. Other names may be trademarks of their respective
  11. owners.
  12. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  13. mysql>CREATE USER 'kefei.huang'@'10.6.16.112' IDENTIFIED BY '*******';
  14. Query OK, 0 rows affected (0.00 sec)
  15. mysql> grant all privileges on *.* to 'kefei.huang'@'%' identified by '*******';
  16. Query OK, 0 rows affected (0.00 sec)
  17. ##查看所有用户
  18. mysql> SELECT User, Host, Password FROM mysql.user;
  19. +-------------+-----------------+-------------------------------------------+
  20. | User | Host | Password |
  21. +-------------+-----------------+-------------------------------------------+
  22. | root | localhost | *E4A535F211A0495CF91B874473B80C07828F31B2 |
  23. | root | login-1-1.local | |
  24. | root | 127.0.0.1 | |
  25. | root | ::1 | |
  26. | | localhost | |
  27. | | login-1-1.local | |
  28. | kefei.huang | 10.6.16.112 | *E4A535F211A0495CF91B874473B80C07828F31B2 |
  29. | kefei.huang | % | *E4A535F211A0495CF91B874473B80C07828F31B2 |
  30. +-------------+-----------------+-------------------------------------------+
  31. 8 rows in set (0.00 sec)
  32. ##查看数据库下所有表格
  33. mysql> use mysql; #切换数据库
  34. mysql> show tables; #查看所有表格
  35. mysql> show grants for 'cactiuser'@'%'; #查看用户权限

好了,基本上就这些了。 有问题大家可以留言。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/人工智能uu/article/detail/872289
推荐阅读
相关标签
  

闽ICP备14008679号