[SOLVED] Clean Install of FreePBX 12 on Ubuntu 14.04 Server, database issues

Hello, I’m using this guide by Andrew Nagy created on Jul 24, 2014 on the wiki freepbx site.

I got up to the step where I run this command

export ASTERISK_DB_PW=`dd if=/dev/urandom bs=1 count=32 2>/dev/null | base64 - | cut -c2-18`

and I realized I had set a MySQL root password already. I tried using the following commands after that and kept getting access denied with password=yes.

So I basically ran the same commands but with a -p at the end, which prompted me each time to enter the password, and it seems to have went through. Now I’m at this command,

[email protected]:/usr/src/freepbx# ./install_amp --installdb --username=asteriskuser --password=${ASTERISK_DB_PW}

Checking for PEAR DB…OK
Checking for PEAR Console::Getopt…OK
Console_Getopt: option requires an argument --password

and now I’m stuck with that “requires an argument” message.

Exported variables last as long as he shell that exported them, just replace ${ASTERISK_DB_PW} (which will be undefined in a new shell) with the password you set for asteriskuser, best off though is to spend some time with a bash tutorial if you want to get the best out of your experience, the same could be said for your mysql interactions, sooner or late, you will REALLY need to understand why you are typing stuff, and not just hoping it will magically work :slight_smile: .

I know that was a variable, I’m just not a Linux user, but I believe I may have found a potential error. The keyboard I was using has that “fn” key you have to press for certain keys, and whatever I was typing for the mysql root password is wrong, so I ran this command to change the mysql root password (not even sure if its the correct way)

dpkg-reconfigure mysql-server-5.5

I started the mysql steps again, I dropped the asterisk and asteriskcdrdb databases, and created them again using:

mysqladmin -u root create asterisk -p
mysqladmin -u root create asteriskcdrdb -p

I then ran these commands

mysql -u root -e "GRANT ALL PRIVILEGES ON asterisk.* TO [email protected] IDENTIFIED BY '${ASTERISK_DB_PW}';"

mysql -u root -e “GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO [email protected] IDENTIFIED BY ‘${ASTERISK_DB_PW}’;”

mysql -u root -e “flush privileges;”

but replacing the password variables with the mysql password, which seems to have worked, but when I run

./install_amp --installdb --username=asteriskuser --password=mypassword

I get

Connecting to database…FAILED
Try running ./install_amp --username=user --password=pass (using your own user and pass)
[FATAL] Cannot connect to database

Again, if ${ASTERISK_DB_PW} is NOT defined, (if you didn’t define it, it is a NULL string) then it won’t work

When you can from bash successfully login to mysql with:-

mysql -u asteriskuser -pmypassword


mysql -u asteriskuser -p${ASTERISK_DB_PW}

(no space between the -p and the password) then you can continue, until then it won’t work.

Again, I’m not using the password variable as stated in my previous post, I replaced them all with what the password should be. What’s the proper way to reset the mysql root password with Ubuntu 14.04? All the guides I’m seeing are outdated.

In your case I would suggest you

apt-get remove mysql-server;apt-get install mysql-server

and read the script again, this time with attention, it is not “out of date” and should work for all Debian 8 based distros (as is yours)

I already did, I copied and pasted the password into Putty for the mysql root password, of course it doesn’t work

mysqladmin -u root create asterisk -pwhatever

leaves me with, access denied for user root

However, when I use

mysqladmin -u root create asterisk -p

I get prompted to enter in the password, I enter it in, and I’m able to execute the command.

Then you are doing it wrong, if you reinstalled mysql without a root password then you won’t need -p if you are root and if you did then it would have to be the same password.

for the syntax in calling the binaries:-

man mysql
man mysqladmin
man mysql (tab complete for all the choices)

There are many tutorials out there for how to interact with the various mysql binaries, you should read some.

An Ubuntu thought from the past, Are you running all this as root?

I login as another account then elevate to have root access by using sudo -i

Then I have no idea. that methadology has worked for me for many years and is working for me right now on a brand spanking new VM, the only difference I can see is that I don’t use windoze, ever maybe the copy and paste is broken. I would start over from scratch and follow the script step by step, I can pretty well guarantee success if you are diligent.

Yeah, almost done on a new install, not using a wireless keyboard and not copying/pasting passwords.

Not sure whether it’s your problem or not, but Ubuntu and Debian servers automatically create a debian-sys-maint user and the credentials for that user in the mysql.user table must match the entry in /etc/mysql/debian.cnf. When those get out of sync, MySQL won’t start which means Asterisk and FreePBX won’t either.

I started the install from scratch again, everything works. The new main page GUI looks fancy. Thanks everyone.

1 Like

This topic is now closed. New replies are no longer allowed.

Closing per user message marking this resolved…