下載Mysql對應的安裝包;
在mysql目錄下配置my-default.ini
# For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the # *** default location during install, and will be replaced if you # *** upgrade to a newer version of MySQL. [mysqld] # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # These are commonly set, remove the # and set as required. # basedir = ..... # datadir = ..... # port = ..... # server_id = ..... # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES [mysqld] lower_case_table_names=0 #綁定IPv4和3306端口 bind-address=0.0.0.0 port=3306 #設置mysql的安裝目錄 basedir=D:\DevelopSoftware\mysql #設置mysql數據庫的數據的存放目錄 datadir=D:\DevelopSoftware\mysql\data #允許最大連接數 max_connections=200 #設置字符集為utf loose-default-character-set=utf8 character-set-server=utf8 [client] #設置客戶端字符集 loose-default-character-set=utf8 [WinMySQLadmin] Server=D:\DevelopSoftware\mysql\bin\mysqld.exe lower_case_table_names=0 #客戶端導入導出數據用到 secure_file_priv=D:\DevelopSoftware\mysql #開啟mysql binlog #log-bin = D:\DevelopSoftware\mysql\data\mysql_bin log-bin=mysql-bin binlog-format =Row server-id=201801
二、打開cmd.exe程序的時候選擇“用管理員身份打開”。
在mysql的bin目錄下面執行: 再輸入mysqld install回車運行就行了,注意是是mysqld,不是mysql。
安裝成功后,有人直接輸入mysql -uroot -p之后然后回車,仍然提示連接不上數據庫,這是為何?這是因為安裝mysql成功后,還要開啟mysql服務才能使用。在任務管理器中打開mysql服務,如果沒找到這個服務,先在bin里面運行,mysql.exe
三、修改密碼:
格式:mysql> set password for 用戶名@localhost = password('新密碼');
例子:mysql> set password for root@localhost = password('123456');