安装完MySQL后,需要进行一些基础配置工作:
#######安装成功后,将其加入开机启动 [root@typecodes ~]# systemctl enable mysqld #######启动mysql服务进程 [root@typecodes ~]# systemctl start mysqld #######配置mysql(设置密码等) [root@typecodes ~]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MySQL to secure it, we'll need the current password for the root user. If you've just installed MySQL, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MySQL root user without the proper authorisation.
Set root password? [Y/n] y [设置root用户密码] New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y [删除匿名用户] ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y [禁止root远程登录] ... Success! By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y [删除test数据库] - Dropping test database... ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist ... Failed! Not critical, keep moving... - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y [刷新权限] ... Success! All done! If you've completed all of the above steps, your MySQL installation should now be secure. Thanks for using MySQL! Cleaning up...
4.可能有效的MySQL配置优化
在原始配置文件 /etc/my.cnf 基础上,在 [mysqld] 节内增加配置参数。实际应用中,请按硬件及负载酌情修改。
#add by feng 120418 -------------------------- #skip-locking skip-name-resolve skip-external-locking key_buffer_size = 256M #table_cache = 3072 table_open_cache = 3072 read_buffer_size = 2M read_rnd_buffer_size = 2M sort_buffer_size = 2M myisam_sort_buffer_size = 256M thread_cache_size = 8 query_cache_size= 512M query_cache_limit= 5M tmp_table_size=1024M max_heap_table_size=3000M max_allowed_packet = 16M innodb_buffer_pool_size = 512M innodb_log_file_size = 512M innodb_additional_mem_pool_size=512M innodb_log_buffer_size=64M max_connections=2000 max_user_connections=800 join_buffer_size = 8M open_files_limit = 65535 #tmpdir=/dev/shm max_connect_errors=1000 #add by feng 120418 end ---------------------
更多Mysql内容来自木庄网络博客
标签:Mysql
相关阅读 >>
mysql 5.7.18 利用mysql proxies_priv实现类似用户组管理实例分享
更多相关阅读请进入《mysql》频道 >>
数据库系统概念 第6版
本书主要讲述了数据模型、基于对象的数据库和XML、数据存储和查询、事务管理、体系结构等方面的内容。