在Ubuntu上安装mysql没有密码提示 [英] install mysql on ubuntu without password prompt

查看:184
本文介绍了在Ubuntu上安装mysql没有密码提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何编写一个脚本来安装在Ubuntu MySQL服务器?

sudo易于得到安装mysql 将安装,还要求提供密码在控制台中输入。

如何做到这一点在非交互的方式?也就是说,写一个脚本,可以提供密码?

 #!/斌/庆典
sudo易于得到安装mysql#安装MySQL服务器#如何编写脚本,以MySQL root用户的​​密码分配
# 结束


解决方案

 须藤的debconf设置,选择<<< MySQL的服务器的MySQL服务器/ root用户口令密码your_password
须藤的debconf设置,选择<<< MySQL的服务器的MySQL服务器/ root_password_again密码your_password
sudo易于得到-y安装mysql服务器

与所需的root密码更换your_password。 (似乎your_password也可以留空空白root密码。)

如果你的shell不支持的这里串的(的zsh ksh93的的和的庆典的支持他们) ,用途:

 呼应... |须藤的debconf-设置选项

How to write a script to install MySQL server on Ubuntu?

sudo apt-get install mysql will install, but also ask for a password to be entered in the console.

How to do this in a non-interactive way? That is, write a script that can provide the password?

#!/bin/bash
sudo apt-get install mysql  # To install mysql server

# How to write script for assigning password to mysql root user
# End

解决方案

sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password your_password'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password your_password'
sudo apt-get -y install mysql-server

Replace your_password with the desired root password. (it seems your_password can also be left blank for a blank root password.)

If your shell doesn't support here-strings (zsh, ksh93 and bash support them), use:

echo ... | sudo debconf-set-selections 

这篇关于在Ubuntu上安装mysql没有密码提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆