Changing the MySQL password
Note: Some distributions that include FreePBX and Asterisk have their own way of managing passwords. If you are new to FreePBX, and are using a distribution that includes FreePBX and Asterisk, you may want to read the instructions that came with your installation package to see if there is a script you should run, or some other mechanism for modifying system passwords.
If you are using the default password, you will see the message:
Warning: You are running freePBX and mysql with the default password
Running with the default password is a bad idea, simply because everyone else in the world knows it, and (if not properly firewalled, etc etc) could potentially connect to your mysql server and do bad things(tm).
Warning: Don't get cute and try to use a password with non-alphabetic or non-numeric characters - things may break in strange ways if you try to use punctuation characters in passwords. Unless you really know what you are doing, stick to numbers and standard alphabetic characters.
Changing the mysql password
There are multiple ways to change the password in mysql.
Using mysql admin
This requires that you know the existing password. From a shell, run:
mysqladmin -u asteriskuser -p password newpass
where asteriskuser is the username (asteriskuser is typically the default username in FreePBX), and newpass is your new password. You will be prompted for the old password interactively.
Using phpMyAdmin
Log into phpMyAdmin, and select Privileges from the main page. From there, select the user you want to edit, and click the edit icon next to their name.
Note on multiple username entries: Note that sometimes there will be multiple user names with different hosts. MySQL identifies users based on the hostname they're connecting from, and allows different passwords for users when they connect from different hosts. Often there is an entry with localhost and another with %. % is a wildcard in MySQL, and means any host in this case. If you have freePBX running on the same machine (which is most likely true) then the localhost entry is a better match than %, so it is the one that will be used. You can usually safely delete the % entry if you're not using it. If you are using a different host, it's better to use that specific host's name or IP than %. See MySQL documentation for more information.
Scroll down to the "change password" section, and enter the new password.
Using SQL
Connect to the mysql interactive shell:
mysql -u username -p
Usually you will use root or another user with administrative privileges as the username.
Run the following SQL command:
SET PASSWORD FOR asteriskuser@localhost=PASSWORD('newpass');
asteriskuser should be the username of the freePBX user. localhost should only be changed if your freePBX and MySQL servers are different machines. Be sure to include quotes around the new password.
type quit to return to the OS shell.
Verifying the password
If you want to be sure that the password has been changed, run:
mysql -u asteriskuser -p
amportal.conf, cdr_mysql.conf, res_mysql.conf
Once the password works, you need to update three files:
- /etc/amportal.conf:
AMPDBUSER=asteriskuser
AMPDBPASS=mypass
- /etc/asterisk/cdr_mysql.conf:
password=mypass
user=asteriskuser
- /etc/asterisk/res_mysql.conf:
dbuser = asteriskuser
dbpass = mypass
Where asteriskuser is the username (asteriskuser is the typical FreePBX default username) and mypass is the changed password.
(Thanks to gstueve for the comment regarding the latter two files.)
- Printer-friendly version
- Login or register to post comments



If you have myPHPadmin set change there also
Make sure you update the myPHPadmin module config file for the new password.
Thanks Paris
file missing
Missing this file:
/etc/asterisk/res_mysql.conf
i have asteriskNOW 1.5.0 and
i have asteriskNOW 1.5.0 and res_mysql.conf file is missing.
sounds like you don't have a
sounds like you don't have a good complete install. res_mysql.conf is placed in the location documented with you install the asterisk-addon's.
If you google res_mysql.conf you'll find a host of information.
One more change required in /etc/amportal.conf
At the very bottom of the file you must change the AMPDBPASS as well.
# SERVERINTITLE if set to true, the browser title will be preceded with the server name. default false
SERVERINTITLE=false
AMPDBNAME=asterisk
AMPDBUSER=asteriskuser
AMPDBPASS=CHANGE THIS ONE AS WELL
ASTETCDIR=/etc/asterisk
ASTMODDIR=/usr/lib/asterisk/modules
ASTVARLIBDIR=/var/lib/asterisk
ASTAGIDIR=/var/lib/asterisk/agi-bin
ASTSPOOLDIR=/var/spool/asterisk
ASTRUNDIR=/var/run/asterisk
ASTLOGDIR=/var/log/asterisk
The editing of this value is
The editing of this value is mentioned in the initial post (see 11 lines from the botom). If you somehow have any duplicate variable's defined in the amportal.conf file REMOVE THE SECOND ONE, otherwise this will do nothing but cause you grief.
ALSO EDIT
Was getting this error after changing the pw, but its fixed now:
"FATAL ERROR
DB Error: connect failed"
Don't know if this is specific to Trixbox or any FreePBX, but I also had to edit this file before the web interface would work:
need to edit the password in:
/var/www/html/maint/modules/cdrreport/config/database.php
Just don't use any special characters like !@#$%^&*() in your password, unless you know how to set up literal strings, which I can't remember how to do at the moment.
That is a trixbox specific issue
That is a trixbox specific issue and yet another reason to not use them.
The Trixbox CD development team (which mostly was laid off in the last few weeks) has taken FreePBX code and forked it (some say to break it) jsut to be different.
To prove this point that module does not exist in FreePBX so it is clearly a Trixbox issue.
Thought so
I had a feeling it would be. To me though, Trixbox CE is worth it just for the endpoint manager (phone provisioning tool). It makes rolling out the Cisco and Linksys phones a breeze where they were a royal pain before.
trix
are for kids. [ like the old cereal commercial ]
seriously, I started using Trixbox and it was a great starting point. endpoint manager is the only thing I miss. but any system based on rpm's will never be as stable as debian.
now we are using Debian + asterisk from source + freepbx. protecting /etc and rock solid upgrades are the main benefit of Debian.
anyways I wanted to say that this how to worked great.
It will not work great for Trixbox as the next Trixbox upgrade may overwrite their file in /var/www/..